I’ll be the first to admit that I’m a bit on the anal-retentive side. Ok, a lot. And nowhere more so than in my source code. I like my code tidy. I break my code into logical, easy-to-use units. I give modules meaningful names. I get rid of unused variables, methods, and units. I don’t leave test versions of units laying around. If you’re handed code I wrote, you can know with certainty that it contains what it needs, and nothing that it doesn’t.
You see where this is heading, don’t you?
The code base that we were handed a year ago was, it goes without saying, a bit sloppy. Just a tiny bit. There were 1050 Pascal source files, comprising over 660,000 lines of code, or about 380,000 actual code statements (lines of code that aren’t comments or white space).
There was some overall structure to it, though it strayed from the plan in a lot of places. As we started digging in and getting familiar, we began to find files that simply weren’t used. And plenty of unused pieces of code in files that were used. And we started cleaning it up. Test versions, backups, copies of copies, duplicates, programs that never got past the crude UI phase. Lots. Of. Junk.
Today, the system has been whittled down to ‘only’ 640 Pascal files; 450,000 lines; 270,000 statements. Or put another way, depending on which metric you use we have been able to delete between 30% and 40% of the code we were given, as it was never, ever used. More, really, once you take into consideration all the new code we’ve written – that’s included in the current totals.
About once a week I come across yet another unused file or method and get rid of it. I have a nagging suspicion that we’ll still be finding them a year from now.
How in the hell does someone let their code base get that messed up? Forget my anal-retentive nature – a basic sense of pride in a job well done should prohibit that sort of sloppiness. Or hell, just the necessity of maintaining the code should be enough to encourage at least some neatness.