Saturday, June 24. 2006DebuggersI was asked this week what debugger I use for Ruby code. The short answer is that I don't. I almost never use a debugger in any language.
I find that, for myself, relying on a debugger leads to sloppy thinking. When I start single stepping through code, I'm reacting to what individual lines are doing and I'm not thinking about the bigger picture. The debugger throws massive amounts of information at me and I'm forced to sift through it to find the tiny details I care about. When I don't use a debugger, I'm forced to actually think about the code rather than just reacting to it. I'm forced to think about how it works and what could possibly be going wrong. A bit of thinking is usually enough to narrow the problem to a small handful of possible places in the code. A few strategically placed print statements then give me the few details that I actually need to identify and fix the problem. Now I said above that I "almost never" use a debugger. Let's look at that. I found myself working on some code a while back that was extremely difficult to understand. The code was littered with Java™ Beans that contained objects of indeterminate types and it was impossible to understand what kinds of objects were being passed around just by looking at the code. Good naming conventions or strategically placed comments would have worked wonders here, however, the original developers didn't seem to believe in either. On this particular project, I found myself using a debugger for days at a time just to be able to figure out what the code was doing. Aside from this one project, I don't think I've used a debugger in any language in the last ten years. There was a time before that, that I relied heavily on debuggers and felt that they were one of the best tools in my arsenal. It was devastating then when I had to spend a couple of years on a project where debuggers just weren't available. While working on this project, I was forced to develop other techniques for debugging that didn't involve an actual debugger and discovered that a bit of thinking was often better than single stepping through code. By the time I had debuggers available to me again, I had developed a better level of critical thinking and realized that the debuggers were really not helping me as much as I'd thought. In fact, I believe that relying on them had led me down the path of sloppy thinking. Today, a debugger is a tool of last resort. I would certainly use one if I felt it would be effective, however, it is usually not the best tool for the job. Trackbacks
Trackback specific URI for this entry No Trackbacks
|