Use The Debugger

While one major use of the debugger is already covered in Ask The Code, perhaps Use The Debugger might refer to the technique of proactively stepping through newly-written code with the debugger to make sure right then and there that it is actually doing what you think it is doing.

Even if the code passes the Unit Test that you've thoughtfully provided by using Code Unit Test First, it doesn't necessarily follow that the code is correct, only that it passes a single unit test; stepping through the code could still be enlightening.

This technique is advocated by Steve Maguire, a former Microsoft developer, in his book Writing Solid Code. (He also has another interesting book called Debugging the Development Process.)


XP developers may think that they should Forget The Debugger. But, if you use "assert" statements in your code, the debugger can really be your friend; it can stop the program right where things are going wrong, and give you a chance to see what's gone off.

Also, if you can change code while debugging, it can help you achieve Just In Time Development - helping you Code Unit Test First, as when they fail, you can change/write code right there, and press "go" to continue.

Coding in the debugger can be done (more or less) in...

newer versions of other Micro Soft "visual" tools, including C++

[others???]


Stepping through code in the debugger is also an excellent way to learn how your language works. The learning curve to internalise an unfamiliar language that you can't step through is much longer. -- Dominic Cronin


See original on c2.com