A customer told me once: "That's the problem with you programmers - each time I ask one to take over the work, the first thing I hear is how the previous guy did it all wrong and everything need to be redone"
That was brutal - but not without ground.
Even worse - it's something I've been thinking/saying more time than I'm confortable to admit. Let's be honest, how many time were you handled a project/code base and though "Waw that's super great, I'm really thankful to whoever did this!" - probably much less than the number of times you though "What a mess" or "why would anyone do that this way?".
About the job
Aside from all the problems of style and taste, I think some root cause here is based on an incredible fallacy of our industry that most of us have internalized to the point of not even putting it in question - that is, that our job is about producing good or even great code.
The reality is - we're not paid to make the best available software. We're paid to do a reasonably working software in a reasonable amount of time for a reasonable amount of money.
It's something that I've been at peace with since years already - mostly because it's the only logical way of operating for the company. Regardless of the profit/non profit status, it's all about economics - ie producing value fast and regularly enough. Both aspects are important - this is not a plead for dirty work, it's that code is just a means to an end that happens inside economic constraints (time, money).
Judging intentions versus acts
Another way to look at that is the usual "We judge ourselves by our intentions and others by their acts" - or in this case, their code. What we usually miss in those situations are the conditions in which that "bad" code was created. Maybe the programmmer was young and inexperienced? Maybe they were new to that technology/context? Maybe they were just given three days to make it work and promised themselves they would clean it after - before being sucked in another emergency?
We've all produced code under less-than-stellar circumstances - and we would clearly invoke them in our defense should that code be challenged "Yeah, I know, this was done in a single evening after a sleepless night with my sick kid while requirements where changing on a daily basis". Heck, I coded a full prototype "between diapers changes" a while ago.
This is going to happen again - and remember that you are someone's else previous guy. So let's start showing some empathy and understanding to that person - even if we don't know them at all.
Most of us want to do a decent job - that's probably what the previous guy wanted to do too.
Opinions? Let me know on Twitter!