Saturday, November 22, 2008
The No-Output Debugging Technique
I run into this situation now and then by accident. If I could just figure out how to bottle it, all the world's software problems would be solved!
Here's the scenario:
- Notice a slight bug in some program output (typically a web page).
- Make the obvious code change, reload the page, bug is still there.
- Make more aggressive code change, making code more modular. Still no dice.
- Add several assertions, improve default assignments. Make control flow easier to follow. Comment the heck out of everything. Still the same bad output.
- Put in some impossible-to-ignore condition: remove the procedure, or always raise an exception, or print some big banner with debug info. Still the same page as before!
- Notice I'm loading the production version of the page instead of the test version. Try the right version with the updated code. Bug was fixed by very first edit.
This is a great way to trick yourself into writing better code.