Vous êtes sur la page 1sur 1

Debugging

Recognizing and fixing errors


steps
1) Recognize that a bug exists
2) Make the bug reproducible
3) Identify the cause
4) Fix it and test
5) Look for similar errors elsewhere
Recognizing a bug
a) Run tests
b) Try unusual data sets (edge cases)
Make it reproducible
a) With random numbers, set seed(123)
b) Know the inputs
c) Start with an empty work space
d) Simplify things as much as possible
e) History gives all commands work out which are necessary
Identify the cause
a) Usually the hardest part
b) Use descriptive names for variables
c) Break up the work into small pieces and then check each piece
d) watch it running
e) Simulate the program by hand
f) Add displays e.g print(), plot() etc.
g) Use a debugger

Vous aimerez peut-être aussi