Tip #2 Step Through Every Line of Code in a Debugger
By ByronNevins on Jul 28, 2011
This is so simple. The place where I catch most of my bugs -- before the code is even checked-in.
Step Through Every Line of Code You Write in a Debugger
I'm frequently amazed at what I bump into during this pass-through. I've found all sorts of embarrassing problems. You never see them, though, because I caught them before checking in.
Nobody writes bug-free code. But you can check-in bug-free (or nearly so) code.
Some people may counter with: "Oh ho! I have no time to step through the code in a debugger!" My answer is that the time it takes to step through the code in a debugger is normally a tiny percentage of the time it takes to do all of these things:
- Think up what to write
- Write it
- Fix compile errors etc.
- Fix more obvious errors from simple tests
- write unit tests
- write dev tests
- close an issue in Issue Tracker
- check-in comments
- Ask for a code review, get comments, respond. make changes
And I mean every line of code. Modern java debuggers allow you to change values of variables, etc., to force your execution path into error handling code.
If you start do this zealously it may force you into picking up other good development habits too, that make it easier to step-through all of your code.