There's this itch we experience when faced with legacy code that clearly isn't optimal and there's one particular scratching stick that seems irresistible to us. Blame the last developer… “idiot”.
A few things spring to mind when I hear someone relent to the impulsive "this is blah, ...why did the last developer blah".
I've previously found myself tempted to compulsively blurt something derogatory about a previous developers work. Really though, it would just have been an attempt to hide my own areas of ineptitude and would have made the people around me cautious of my attitude.
You Might be Wrong
That’s it. You just might not be that smart right now. It could be that [poorly named native function which causes confusion] was implemented correctly and you just misunderstood the arguments passed to it and the subtleties of the problem the developer was solving.
It Could Have Been You
It probably has been you at some point in the past. Since you don’t know what the developer’s remuneration package was or the circumstances that lead him to duplicate code rather than correctly use a recursive function… you can’t really judge.
You Don’t Know Anything
You actually probably know quite a lot, you were hired based on your experience and found the issue… congrats, now fix it. What you probably won’t know about are previous issues surrounding project budget, time constraints, management and client ineptitude, scope creep, legacy code and a multitude of other gotchas ready to make you look the fool once you’re out the same swing door.
It Doesn’t Sound Nice
We can probably be a bit more constructive than beating the guy over the head or cursing his name. At the least we should just quietly do our job and fix it without drawing attention to the fact that we’re judgmental. If you’re a junior/mid developer, your tech lead will see your refactoring at some point and note it. If you’re a tech lead, you don’t need to point out your obvious expertise.
Bad Code is Always Bad Code
I don't mean to tell anyone off. Good developers are passionate about what they do and if you spot an issue, it has to be called out and dealt with. Incorrect syntax, white space, poor naming conventions, complete lack of refactoring, no documentation, etc. are all problematic going forward.
We’re all making it up as we go along anyway
Honestly, I've never personally met anyone that knew everything… although we’ve all met some people that think they do. There are some really specialised developers out there, the sort that just focus on Nginx microcaching strategies for Drupal. For the rest of us, it’s probably fair to say that we’re reliant on Google and our ability to think laterally and read documentation.
As developers, we're fortunate that we often work with intelligent, collaborative and rational people. Perhaps that's why it seems so at odds to me then to falter to the primitive compulsion of blaming the last guy.