7.3. Debugging by Deduction
The process of deduction proceeds from some general theories or premises, using the processes of elimination and refinement, to arrive at a conclusion (the location of the error). See Figure 7.4.
As opposed to the process of induction in a murder case, for example, where you induce a suspect from the clues, you start with a set of suspects and, by the process of elimination (the gardener has a valid alibi) and refinement (it must be someone with red hair), decide that the butler must have done it. The steps are as follows:
Enumerate the possible causes or hypotheses. The first step is to develop a list of all conceivable causes of the error. They don't have to be complete explanations; they are merely theories to help you structure and analyze the available data.
Figure 7.4. The deductive debugging process.
Use the data to eliminate possible causes. Carefully examine all of the data, particularly by looking for contradictions (Figure 7.2 could be used here), and try to eliminate all but one of the possible causes. If all are eliminated, you need more data through additional test cases to devise new theories. If more than one possible cause remains, select the most probable cause—the prime hypothesis—first.
Refine the remaining hypothesis. The possible cause at this point might be correct, but it is unlikely to be specific enough to pinpoint the error. ...
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.