Wednesday, 21 November 2007

Candidate For Best Comment Ever!

Today, I was given a bug report stating that one of the fields in the system should be 200 by default, yet for some reason it is showing up as 100. Due to my work load someone else investigated the bug before I had a chance to take a look and shortly after he came over to my desk with a big smile on his face.

When he pointed me at the offending code, I instantly realised why he was smiling. Here's my candidate for best comment ever:

static const long INITIAL_PING_SECONDS_REMAINING = 100; //TODO: Needs to be 200
For a few seconds I was stumped. This can't be my code! What was I thinking???? Then it hit me and I remembered what I'd done. I set the constant to 100 during development to make it quicker to debug so I put the TODO there to remind myself to put it back to 200 when finished. Nothing wrong with that of course, but I could have saved myself considerable embarrassment if a) the comment was a little more descriptive like "TODO: 100 for debugging, remember to change back to 200" maybe and b) if I actually checked my TODO's before committing!

Oh well, lessons learned I guess :-)


arsenalist said...


David said...

One way to avoid these kinds of issues: instead of hard-coding debug vs. production things like this, make a "profile" or "config" class/module that encapsulates all these. Then it's just a matter of remembering to use the production config when you go live - which is hard to forget, since there's usually something glaringly wrong if you don't.