As programmers we construct an abstract mental model of the program we’re writing. Bugs are discrepancies between our mental model of the program and the program itself. The program is doing something we don’t expect. The program isn’t wrong. The program can’t be wrong. It’s doing what it’s been told to do. What’s incorrect is our mental model. Once we understand the current state of the program, we can adjust it.
The art of debugging is systematically and creatively synchronizing the mental model with the actual program.How to help a student get unstuck