You’re a consultant. You got sent to this new project, and it has been around for quite a while, and lots of bright and not-so-bright people worked on it over the past few years. Lots of functionality in it, they say, and even though the project has been wildly successful in the business eyes, do you have any idea regarding what to expect from the codebase?
First, you check everything out from the insanely bad SCM tool, to find out your favourite IDE won’t have enough RAM to build the thing, and you’ll have to use something else. You also find out that most tools can’t help you anymore, because they die a horrible death when trying to make sense of all that code.
You try and follow Michael Feather’s brilliant Working Effectively with Legacy Code (PDF link), and manage to isolate a tiny bit of functionality, test it and make sure you can fix the behaviour properly. That gets you trapped in a maze of circular dependencies with some other 30 other packages.
Your vision gets blurry, and you go out looking for something sensible to do, like searching for pictures of screaming trapped babies.
But there’s more. The build is so complex Ant didn’t cut it, and using something built in-house was the best way. But you don’t want to mess with that yet, because you don’t know what else could break. In fact, breathing near some parts of the code could make them break. And it takes time to know it, cause it takes half a day to get feedback from something you committed by the continuous integration machine.
You yearn the days when Find Usages was one of the most valuable keyboard shortcuts in your IDE. When using one O/R mapper was already troublesome enough - instead of the handful you have now.
If you excuse me, I’ll go look at some more pictures of screaming babies.

Jenna | 14-Feb-05 at 7:08 pm | Permalink
Well put.
I find legacy code hardest to understand/fix/improve on when there are no comments, when the naming schemes are easily misunderstood, and when the “genius” programmers who wrote it first think about backdoor ways to fix an issue and don’t want to hear about a way all the rest of the world could logically deduce without being in their brains. Then they look at you funny when you pick up all the spaghetti code and throw it against the wall. What else can you do with it? I don’t even want to touch it anymore.
How do you deal with this kind of code? How do you finally come to understand this stuff, which was made by other brains with crazy schemes and non-object oriented ways of thinking about web applications?
Marcus Brito | 14-Feb-05 at 8:08 pm | Permalink
Sounds a lot like my everyday job on my former employee, excepting the part about the continuous integration machine — there wasn’t any. The fact that I’m still alive proves humans are definitely tough creatures.
Obie | 16-Feb-05 at 12:13 am | Permalink
Hey, you think you have it bad? All the strain of that codebase actually made my notebook die a slow, painful death and I had to get a new one today!
Jeremy | 22-Feb-05 at 4:28 pm | Permalink
I feel for you. I just left TW for a local ISV. My first duty, take a large spaghetti/procedural codebase with little test coverage and start making it TDD’ed and CI’d to extend its effective life. Just as hard as taking over the hairy code, is interacting respectfully with the (very nice) principal developers responsible for the ugly code in the first place without putting their backs up. The great advantage of being a consultant is knowing you’ll get to leave the engagement sooner or later. I get to own the results of my legacy code.
allan | 23-Feb-05 at 6:17 am | Permalink
In my experience, what makes this whole situation even more sad, is the fact that the “legacy code” that I’ve worked with, which is perfectly described by your story, is actually Java code that’s only about a year or two old. It’s not so much “legacy can be tough to deal with”, as “loads of junk code is still being freshly produced in 2005″ …
iain | 03-May-05 at 10:23 am | Permalink
The worst part is that sometimes, the legacy code is yours…
And you’re still writing it.
AIEEE! THE TENTACLES!!!