Addicted to Debugging?

As youDevise gets bigger, I don’t get to pair with developers on my team as often as I’d like – but I always do when asked. One thing that’s really noticeable when you pair with me on a bug assignment is that I don’t use a debugger. Ever. I’ve don’t even know how to start the Eclipse debugger. We might have jdb on our test machines, but I’ve never thought to check. (OK, I just did, and we do, but who cares? Not me.)

I came across this post that makes an eloquent case for throwing away your debugger, at least in most instances. Hans-Eric makes a good argument for using unit tests, which are permanent and expressive, instead of a one-off session with your debugger that only benefits you, not the rest of the team.

Interestingly, most of his reasons for using unit tests instead of the debugger also apply to another of my favourite non-debugger diagnostic tools, the humble log message. Just write

getLogger().debug("Validating idea " + ideaId)

and your message lives on in the code forever, telling readers what you are doing like a comment does but also providing a very useful reality check when you would swear the code in question can’t possibly be executing.

In fact, although I often use them together, I like log messages even better than unit tests because you can use them in production! Change one properties file on one server, and without even a restart you’ve got loads of extra detail about whatever you are investigating. So you can guess what I’ll be turning to next time the phone rings in the middle of the night…

Leave a Reply

Your email address will not be published. Required fields are marked *