Tuesday, June 27, 2006

A buggy lesson


Two nights ago I was laying in my bed just about to fall asleep when I thought I heard a bug trying to fly in my ear. I jumped out of bed, turned the light on and couldn't find him. Finally I went back to bed after not finding the bug and just as I was approaching dreamland, I thought I heard the bug again. This happened several times during the night.

At some point, I started questioning my sanity. I thought maybe my brain was making up sounds that weren't there. Or, maybe my years of loud music had caught up with me and this was some sort of hearing damage.

(There is a coding point to this...) In the morning, I had two gigantic goose egg bites on my right arm. AHA! there was a bug.

At this point, I knew there was a bug and I had to find it. To make a long story short, two nights later and 6 bites total and I caught the bugger!

The moral of this story:
1. When writing programs never give up on a bug.
2. If you can't reproduce it or find evidence of the bug, don't let it drive you insane because it can. Take some time away from it and go back later. In time, you'll be able to isolate it.
3. Where there is one bug, there are usually two. Remember that unit testing can help but the test can only check logic that you coded for. Review your code change at another time you may spot others. (Yes, there were two mosquitos! I found one on the same wall 5 minutes later!!)

Happy Coding!!

No comments:

Post a Comment