7.6. Debugging Principles
In this section, we want to discuss a set of debugging principles that are psychological in nature. As was the case for the testing principles in Chapter 2, many of these debugging principles are intuitively obvious, yet they are often forgotten or overlooked. Since debugging is a two-part process—locating an error and then repairing it—two sets of principles are discussed.
7.6.1. Error-Locating Principles
7.6.1.1. Think
As implied in the previous section, debugging is a problem-solving process. The most effective method of debugging is a mental analysis of the information associated with the error's symptoms. An efficient program debugger should be able to pinpoint most errors without going near a computer.
7.6.1.2. If You Reach an Impasse, Sleep on It
The human subconscious is a potent problem solver. What we often refer to as inspiration is simply the subconscious mind working on a problem when the conscious mind is working on something else such as eating, walking, or watching a movie. If you cannot locate an error in a reasonable amount of time (perhaps 30 minutes for a small program, several hours for a larger one), drop it and work on something else, since your thinking efficiency is about to collapse anyway. After forgetting about the problem for a while, your subconscious mind will have solved the problem, or your conscious mind will be clear for a fresh examination of the symptoms.
7.6.1.3. If You Reach an Impasse, Describe the Problem to ...
Get The Art of Software Testing, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.