Debugging Lecture
Debugging Lecture
Debugging Lecture
A Bug’s Life
History’s first documented bug 3
2. Backtracking
● Start from the statement at which an error symptom has been discovered,
then derive backward till error is discovered. Also challenging as backward
methods might increase.
Approaches 7
3. Cause Elimination
4. Bisection method
● Find approximately the halfway point in your code and print out some
relevant values in your code. If everything looks good, it’s code free, so the
next search area would be in the ¾ area of the code print and try to pinpoint
the place you are getting bad results.
● O(log n) time
Tools
Modern Tools for debugging 10
Depending on your IDE and your setup there are plenty tools built-in to help you debug your
code
● Once you set breakpoint, you can start program in debug mode, it will pause
execution when program reaches the line where breakpoint is set.
Using Built-in Debuggers 12
● Decide what you are going to name the variables you will use over and over again
● If your solution looks unnecessarily complicated, invest time in a simpler one before typing it out.
17
Don’t Do
~ Nicholas Negroponte