Trace your calls and debug your function
- Making assertion
- Trace calls
This week, we did not learn much but some evaluate and debug method to test your
code.
Without question, debugging is so familiar to us ---- a programmer. With the complication
of the code grows, we always spend lots of time to debug code. Sometimes, you may finish
the code for 1 hour but debug it for 4 hours.... I still could feel the anxiety when I am stuck
by a bug.
Since, it is so common in programming. We have to learn some systematic methods to
be applied to fix all bugs in step by step with high efficiency.
1. Making assertion. Making assertion is actually just let the computer to examine if the code
output the result as we want rather than need us to print it out and compare it with our expectation.
The tool is often used in unittest to compare expected result and actual result.
2. Using the debug tools built int the Wing could also enable us to analyse our code in a visible
method. We could check whether the variable changes as we want as the code running.
I seldom complain the experience of debugging. I believe it is also a good exercise for me to
program in more strictly mind and help me accumulate the experience of fixing different kinds of
debug problem.
More you practice, more you learn.
没有评论:
发表评论