Site Archive (Complete)
C++ Blog: Why is debugging so hard?
C++
void main(void)

Calls, Returns and In-Between.

by Kevin Carlson
SELECTIVE IGNORANCE

Finding the Signal in the Noise

by Andrew Koenig
October 09, 2006

Why is debugging so hard?

If you're an experienced programmer, you've surely had the experience of becoming ever more frustrated while trying to understand why your program didn't do what you intended -- only to realize that once you found it, the answer was trivial.

In that sense, debugging seems to differ from other kinds of problem solving. What makes it so different?

I'd like to suggest a reason: We think about what our programs are supposed to do by forming a mental model--an abstraction--of the program's behavior. Whenever that model fails to match the program's actual behavior, our reasoning gives wrong results, even if the reasoning itself is correct.

If my suggestion is correct, then the most frustrating kinds of program misbehavior are those that violate our mental models of how the programs should work. As an example that supports this theory, consider what happens if you exceed the bounds of an array: Anything at all can happen, and sometimes the program seems to work correctly. How can one not be frustrated in modeling such flaky behavior?

By implication, we can make our programs easier to debug by programming in a way that assures us that our mental models are correct.

Posted by Andrew Koenig at 11:03 AM  Permalink




 
INFO-LINK


Related Sites: DotNetJunkies, SD Expo, SqlJunkies