Thursday, August 14, 2008

The Tale of the Extra Semi-Colon

Jeff Atwood in his blog "Coding Horror" had a post recently titled "On Our Project, We're Always 90% Done"

This brings up another pet peeve of mine, the dreaded question "What percent complete is that?"

Software (or parts of software) are either done or in progress. Percent complete is worthless.

Let me tell you the tale of the extra semi-colon.

Long ago in a computer lab far away, a novice C programmer (me) was writing his second C program.

I had a program that looped over all the pixels in an image to do some filter function. The only problem was that the loop wasn't working. It was only executing once.

I made one of the two classic non-pointer C errors1, I had put an extra semi-colon at the end of a for statement like:
for (int i=0; i < 300; i++);
{
//loop body
}

To fix it all I had to do was delete one semi-colon. It only took 3 days for me to find the extra semi-colon. I probably spent about an hour writing the original code.

My question to you is: What percent complete was the code?

My second question is: Does it matter if it's "99%" complete if it doesn't work?

I would argue that the code was actually more than 100% complete. After all to fix it I deleted one character.

The only percent complete that makes sense to me is the number of features complete versus the number of features in the specification. Anything else is pulling a number out of thin air (or other, less pleasant places.)

My answer to "When will that be done?" is "When it's done."



1The other classic mistake is accidentally doing an assignment instead of an equality test. e.g. if (a=10) rather than if (a == 10). I did that a couple of days later. But it only took 4 hours to find.

No comments: