David Thielen said:
What I do is have a method trap(). I place this call at the start of all new
code I write and at the start of every if and else. When I hit these in the
debugger I take them out and trace through the new code I just hit.
This way I make sure I step through every line of code. But in some cases it
is days later that I finally hit one so breakpoints could all be reset by
then.
Hmm. Personally I don't step through every line of code manually. It
seems a waste of time, when unit tests and code coverage tools can make
sure that not only is all my code being tested, but that it does the
right thing, too - in a way which makes it easy to verify that new
changes haven't broken existing desired behaviour.
Last time I was in a discussion like this, however, I hadn't actually
*done* much unit testing. It had only seemed like a really good idea I
was anxious to try out when I got the chance.
I've now been following a test-driven development model for about 8
months. Over the last couple of days, we've been making changes to the
system which we just wouldn't have considered without unit tests. It
would have been *far* too risky - and there's no way we could have gone
through each line of code manually - it would have taken weeks.
Unit testing really rocks. It's not a panacea - it won't absolutely
stop you from writing bad code. It certainly helps to reduce the number
of bugs (and improve design, when coupled with Inversion of Control)
though. I wouldn't dream of going back at this point.