Friday, 15 February, 2002
A Simple Lesson in Debugging
Today's lesson, class, is on the art of finding and fixing bugs. It'll be a very short lesson—just one point for me to make and for you to ponder. When you're trying to find a bug, make as few changes as possible to the code. Doing otherwise risks introducing new bugs or, worse, masking rather than fixing the problem. And debugging is not the time when you optimize that routine you've been thinking about, or rewrite some code that you think is ugly. Working is more important than fast, and until you get it working you can't know where the real bottlenecks are, so any optimization you make is at best wishful thinking.
It's such a simple lesson, and painfully obvious to anybody who takes a few minutes to think it over. Why do so many programmers ignore it?