Thursday, March 13, 2008

Code is Shit

Please forgive what appears to be a regression in my language usage. But I'm working with more code written by an expensive contractor and I've just got to say this because bad code is definitely a source of more overtime. It's hard to manage and hard to decipher and suffers higher risk for defects. I'd told this individual several times to try and reduce the complexity of the code and several times this advice fell on deaf ears. This individual is smart, and that's part of the problem. Code that doesn't seem complicated to her is in fact very ugly to the rest of us on the team; not necessarily because the rest of us are stupid but because we will live with this code far longer than the person writing it and well past the point when this person is no longer around.

How can I do a better job of explaining the difference between using introductory versus advanced techniques? Maybe I have to start with changing the attitude about code. Instead of treating code as something beautiful, which it rarely is, perhaps I should start calling it shit. Oh my, a four letter word!

However, there is precedent for my approach. J. van Mannen is a criminologist who has published books on his studies of police work. He has a term he uses to describe any difficult individual law enforcement must deal with: "The Asshole." I'm not kidding, you can look this up. I learned of this when I took a criminology class at UC Irvine taught by James Dombrink.

Just as van Mannen could find no more concise or accurate a term as "the asshole" to describe this element of the population, "shit" is a fine way to describe code. Think about it: would you rather manage a cup of rabbit turds or shovelfuls of horse manure? This also ties in nicely with what expert developers will tell you about the difference between novice and advanced developers. New or thoughtless developers are usually all about hacking away and adding what they can. Increasing the amount of code is considered good programming and even fun. But an experienced developer understands that the best practice is not about adding code but reducing it.

Code is shit. Improving it is not about what you can keep piling on, but about what you can take away.