The author discusses about debugging in this chapter. The author provides a study to show the difference in time it takes for best and worst programmers to debug a program and the errors that get introduced while correcting the existing errors and the difference is huge.
The author then provides a list of things that a programmer can learn while debugging or fixing an error. The author also provides a list of ineffective approaches while debugging an error.
The author then provides a scientific method of debugging with following steps:
The author then provides some tips on fixing errors:
The author then provides a list of things that a programmer can learn while debugging or fixing an error. The author also provides a list of ineffective approaches while debugging an error.
The author then provides a scientific method of debugging with following steps:
- Gather data through repeatable experiments/Stabilize the error
- Form a hypothesis that accounts for as much of the relevant data as possible/Locate the source of the error
- Design an experiment to prove or disprove the hypothesis/Fix the error
- Prove or disprove the hypothesis/Test the fix
- Repeat as needed/Look for similar errors
- Use all the data available to make your hypothesis
- Refine the test cases that produce the error
- Reproduce the error several different ways
- Generate more data to generate more hypothesis
- Use the results of negative tests
- Brainstorm for possible hypothesis
- Narrow the suspicious region of the code
- Be suspicious of routines that have had errors before
- Check code that has changed recently
- Expand the suspicious region of the code
- Integrate incrementally
- Use brute force
- Set a maximum time for quick and dirty debugging
- Check for common errors
- Talk to someone else about the problem
- Take a break from the problem
The author then provides some tips on fixing errors:
- Understand the problem
- Understand the program
- Confirm the error diagnosis
- Relax
- Save the original source code
- Fix the problem not the symptom
- Make one change at a time
- Check your fix
- Look for similar errors
- Source code comparator
- Execution profiler
- Debugger
No comments:
Post a Comment