Wednesday, November 02, 2005

The Scars We Bear

Wow, you're still here! When my key still let me into the building, I chalked it up to lazy management. I figure pretty soon I'll show up and be locked out.

I was watching an old war movie, and it kept reminding me of software development. If that sounds sad, I'll leave it to you to decide which is sadder, that old worn-out war cliches can be applied just about anywhere or that there is someone willing to stretch them even farther.

You are in the mountains on a poorly-maintained dirt road leading up to a large encampment; an extremely busy tent city that looks as worse for the wear as the road you're on. People are all running everywhere, yelling to anyone who'll listen. Ok, ok, if you've ever watched M.A.S.H. you get the picture.

Sitting serenely at the edge of the camp is a sign that simply states "Hospital". Some jokester has added a hand-written sign to one side that reads, "Surgery while-you-wait, anesthesia extra, hack jobs our specialty." The tinny-sounding PA system is playing a familiar tune, occasionally interrupted by various announcements like, "Tonights movie is Godzilla vs. Gumby." When you are able to make out the song, the lyrics go something like this:

[M.A.S.H. Theme]
Source control is painless
It takes on all your changes

and I can take or leave it if I please.

Enough of that. I'll skip ahead to the juicy bits. You're looking over the shoulder of someone wielding a bloody bone-saw, a surgeon you hope, hurriedly working on a prone patient.

"Dr, is it bad?", says a guy that looks like the patients commanding officer.
"Of course it's bad! Just look at all that scar tissue! How many times have we worked on this guy?", says the guy with the saw.
"This is the second time this month. How much longer do we have?"
"The patch job from last time is all messed up. Once I stop the bleeding we can fix that broken leg."
"We don't have time for that! We'll just send him back to the front with a splint and some crutches; his buddies can support him until this crisis passes."
"If you say so. I can patch 'em up again but it'll be temporary even in the best case. "
"That's ok doc, we'll lose the battle if we don't."

The guy with the saw turns around; you are taken aback. When you go to look at him, you find yourself looking at yourself! Oh, ok. Maybe that was a little on the dramatic side. You thought we were here to talk software, not surgery. Was that a Twilight Zone moment or would you prefer The Empire Strikes Back?.

And now back to our code. Did I forget to mention the Hospital sign says at the bottom, "Supporting your Software Maintenance Needs"? Didn't you know that a keyboard is like a scalpel? You can amputate, graft, transplant or even give a facelift. I heard that! What about boob jobs? I'm not against giving jobs to boobs but aren't there enough of them working as programmers already? *bah-dum-dum!*

So, what's the problem? The problem is scarred code; regardless of platform, language, or even political affiliation. Clogging your source, like lumps under the skin with their fibrous tendrils choking the life out your methods and making your classes uncouth.

Here is one of the simplest examples of scar tissue.

// Date begin1099year;
Date year;

An old variable that has been left in a comment to rot. I'm not talking about the times when you comment something out while deciding on a solution, maybe while debugging. I'm talking about code that has been checked into source control, scar intact. You've all seen it, whole methods commented out; line after line, like a vast wasteland.

"I'd like to clean this up but I don't have time!" we tell ourselves. "We'll come back later and fix it" should rate right up there with "The check is in the mail" and "I'm from the government and I'm here to help". "I need to be consistent even though I don't like the stuff that is in there", we say to soothe our conscience as we add to the problem. "It's already so scarred that one more won't hurt". In other words, yes it is a tumor but it is benign. So like Alfred E. Newman likes to say, "What? Me worry?" So slowly, without outcry, a pattern is established. If enough scarring is allowed to collect and that pattern, like history, repeats itself -- with apologies to Mr. Simon -- silently the scars, like a cancer, grows until they are everywhere, metastasizing even into the code of other applications.

Why do we still see commented-out code from years ago still in the source file? Why do we still come across programs that look like they are the hastily put-together compiler-spawn of the developer equivalent of Dr. Frankenstein? I have to watch out when I ask those questions, I end up trying to understand the mind of a code monkey and I wouldn't want any of their habits to rub off on me.

If you could bring these code monkeys to justice, what would be an appropriate punishment? If you let your imagination loose, you might come up with the following. Force them to sit in a brightly lit room and watch a computer screen, with no glare-guard, scroll through badly formed HTML pages overloaded with <blink> tags and cute "Under Construction" signs while listening to The Hamster Dance? Oops, we might have overdone it, the evil giggling from the section in the corner is starting to creep me out.

Indeed, let's keep the brightly lit room and the glaring screen and give them the standard third-degree. When interrogated, the code monkey might tell you, "But I might need that later!" Do they think it might go missing if they don't keep it around? Reminds me of the old couple that keeps stacks and stacks of every newspaper they ever received 'just in case we need it later'.

How about, "I'm not sure if it needs to be deleted yet!" The Code Police might let you off with a warning but you better be debugging. Comments are not like fiber for a compiler you know, more won't keep it healthy.

"I don't want to check in my code yet, it isn't finished!", which is a whopper. Are they hoarding code? Do they think they are working on the next Mona Lisa? Can you imagine what would happen if that happened in construction? The carpenters show up to put up the walls and the guys pouring the foundation say, "You can't see the foundation yet, it isn't dry." Without seeing the foundation, how can the carpenters plan when to start adding onto the foundation, not to mention checking to see if the foundation matches the blueprints?

"The stuff I write is so good, surely somebody will need it later!" Is that raw, unfiltered arrogance I smell? I have news for them. I have a use for it right now, as digital litter lining the cyber cat-box for my virtual feline. Too bad I don't have one, guess I'll just throw all the scar tissue code in the bit-bucket. Check http://stackoverflow.com/ for more programming jargon.
Back to the code. I was thinking the other day (don't say I didn't warn you about that) when you are working on code, do you feel like you are in a war zone, elbow deep in the digital entrails of some hapless script and a hack job is all you feel you have time for while working on your current program? Or do you take the approach that you are a highly-paid neurosurgeon who uses the latest in technology to perform miracles with the slightest of incisions upon the executable that is your patient?

I'll let you think on that. Good night and thanks for all the fish.

[The lights go out]
Hey! I thought I put plenty of time in that meter. Cheapskate landlord. Ah, here it is. Let me put in another quarter.

[Click! Music starts to play.]
I found the jukebox!

[From backstage you hear]

Hello darkness, my old friend.
I've come to talk with you again...


Delicious Bookmark this on Delicious