Debugging (What causes bugs? (Coding wrong (Not properly understanding…
What causes bugs?
Program logic wrong
Not properly understanding something
Methods of library classes
Check the documentation
Bug in underlying language or operating system environment (rare but difficult to overcome)
What do we want to do?
Find the cause of the bug
Know the reasons for common exceptions
Track it down
Find where it occurs
Print statements to inspect state of variables at strategic points
Wolf-fencing (also know as binary search or divide and conquer)
If there is a crash look at the stack trace
Only change one thing at a time
Keep a last good version and if a bug appears look for what is different
Debugger may help but has significant learning overhead
Fix the bug
What is a bug?
Running program produces incorrect output or doesn't behave as expected
State of mind
Can we reproduce the bug?
If so we can fix it!