The Correct Way to Debug
Do the opposite of devil debugging...
- Scatter print statements everywhere
- Try things at random till the bug
goes Proceed systematically
- Never backup earlier versions
Backup everything (use git!)
- Don't bother understanding what the program should do
Understand what the program should do
- Use the most obvious fix - fix the symptom
not the problem (e.g. hack in the right answer)
Fix the problem, not the symptom
You should...
- Understand what the problem is
- Understand what the code should do
- Be able to predict how the fix will address the problem (the
cause not the symptom)
Failures, Errors and Defects
Definitions
- Errors Things that are not correct, right or true.
- Failures A problem that is visible by the user resulting
from an error in the code.
- Defects are errors that are hidden within the code. It
turns valid input into a failure. (Also known as a fault, or a bug).
Propagation
- Defects lead to 'infections'
- Infections can be propagated to further infections
- Infections may die out
- Infections can be lead to a failure