Debugging by induction
Transcript of Debugging by induction
Prepared By Waqar Ali
Software EngineerAbasyn University Peshawar
Debugging By Induction
codesmaker.blogspot.com
Debugging by Induction
Many errors can be found by using a disciplined thought process without ever going near the computer.• One such thought process is induction which can figure out
the solution to a problem• You start with your own experience and then generalize a rule
Introduction
What?
So what is meant by debugging by induction?
• Induction is a debugging strategy • In other words it is called reasoning or thoughtful strategy
Induction debugging start with the symptoms of the error, possibly in the result of one or more test cases, and looking for relationships among the symptoms, the error is often uncovered.
ExampleLet’s take an General Example
For example, because the last few times I cut my hair, it grew back. Inductive reasoning allows me to generalize that after I cut my hair it will always grow back.
For example, The last ten times I touched the hot stove I burned my hand. I bet every time I touch the hot stove my hand will be burned.
How
How to perform induction strategy?
To perform induction strategy, a number of steps are followed, which are listed below.
1. Locating relevant data: All the information about a program is collected to identify the functions, which are executed correctly and incorrectly.
2. Organizing data: The collected data is organized according to importance. The data can consist of possible symptoms of errors, their location in the program, the time at which the symptoms occur during the execution of the program and the effect of these symptoms on the program.
FormThis is a form used for organizing the data
Cont…
3. Devising hypothesis: The relationships among the symptoms are studied and a hypothesis is devised that provides the hints about the possible causes of error.
4. Proving hypothesis: In the final step, the hypothesis needs to be proved. It is done by comparing the data in the hypothesis
with the original data to ensure that the hypothesis explains the existence of hints completely. In case, the hypothesis is unable to explain the existence of hints, it is either incomplete or contains multiple errors in it.
Cont…5. Fix the problem: • You can proceed with fixing the problem once you complete
the previous steps. • By taking the time to fully work through each step, you can feel confident that your fix will correct the bug.• Remember though, that you still need to perform some type of regression testing to ensure your bug fix didn’t create problems in other program areas. • As the application grows larger, so does the likelihood that your fix will cause problems elsewhere.