Here is my story... I work as a web developer at a SME somewhere in far east. So far I have worked in couple of small to large scale Agile projects. And yes, I had company of college interns, developers, senior developers, consultants and architects alike. To be brutally honest, I abhorred my senior's work with a passion. I always pondered how this kind of incompetent, useless people end up handling multi-million dollar worth mission-critical projects.
Based on my so far analysis, this is how I see it:
1. Most of these seniors have survived simply because of a historical reason you might not know.
In my case, most my seniors survived during the 2008-2009 retrench season. Some survived totally through political clout; some by sacrificing their salary and other benefits. So in management's point of view, these are really valuable employees, and they should retain them at every cost.
2. They were there at the right time.
Around the time they were promoted, may be there weren't anybody to around to challenge them. After all the good crop leaves a firm, there is a window for all the sloppy bafoons to inflate their ego, convince management and climb the promotion ladder without much external challenge.
3. They know how to find scapegoats efficiently and effectively pass the buck.
How do I know about this ? I was a victim ! My firm practiced this 'Russian roulette' style of assigning task, such that everyone ends up get to work in every module of a project; or, bugs get assigned to you, even though you never worked on that module before. Most often, these experienced developer's work break down spectacularly, and I am the one brought in to clear their mess; and when I fail to fix, I end up in prison-cell meeting rooms to receive the brunt of senior management. Over the time, these seniors painted this nice picture of me as a lazy, unreliable, incompetent developer. And the funny thing is, most of these code bases, I didn't write a single line of code and I have absolutely no idea what's going inside. And these code bases are poorly documented/commented, making troubleshooting is a mini-IT project it self (call it "reverse engineering feature XYZ")
Sadly for most of us in junior positions, it is an arduous task to challenge the existing establishment. But at least you can dampen or insulate your self from the shocks from these stupidos. Here's what I do:
1. Don't volunteer to amend their codes.
I made this mistake many times as mentioned. Find who originally developed it in your team. If he/she is there, get him/her to work on it. If he is in a different team, ask project manager to bring him/her back. And importantly, if you are taking up these kind of responsibility, have a written understanding with your project manager that "You are doing your best effort to fix the issue, and if it fails, it is not your fault, it is due to poor implementation of the original developer". Stand up for your self ! in corporate world, nobody is there to stand up for you after all.
Trust me on this, "it is good a senior doing a bad patch that temporarily fix the problem and eventually breaks in future, than you failing to do a perfect job in fixing it for posterity"
2. Give seniors a chance !
Don't bother helping them out of your kindness. Let them shoot their own foot. You entering the picture is the biggest disservice you can do to your self, by becoming the dummy they can shoot.
In my current team, I have a tech lead, who was doing an important module. I had plenty of time to help him, as I finished my module early. Instead, I sat down and watched him failing brilliantly and had a silent laugh. Maybe I could have helped him in many ways, but I digressed and let him eat his own dog food.
3. Promote yourself often
I am not very good in this either. But in this world, hardly people pay attention to other individuals. So if there is an opportunity to shine, or talk about your work... just do it! And if management is still deaf and doesn't acknowledge/appreciate your contributions, move to another firm !