Tuesday, February 14, 2006

intepid » The Joy of Debugging:

The Joy of Debugging

Debugging software can be a bit like looking for your keys: More often than not, after hours of cursing and overturning furniture, you’ll find them in a really obvious place, where you could have sworn you had already looked.

There are no prizes for spotting the problem with the following code [especially if I tell you that the main symptom was incomplete or broken lines being drawn]:

void DrawPolyline(int nPoints, const Point* p)
{
for (int i = 0; i < nPoints - 1; i++)
DrawLine(p[0], p[1]);
}

Finding this bleeding obvious error took me a whole day! That’s a day of my life, which I will never get back.

[for the non-programmers, the error is that even though I create a loop to draw each segment of a polyline, I simply redraw the first segment over and over again… an easy error to make, but normally it would be detected almost immediately]

0 Comments:

Post a Comment

<< Home