The colorful wolf

February 4, 2010

De buggery

Filed under: Tech — randy @ 20:43
Tags: ,

I didn’t really know how to use a debugger four years ago, even after I graduated from computer science. Of course the theory behind debugging was taught to me, and we had some practical tests too, but I never really needed it during my education, so it became a neglected skill. When I first arrived here at AK I realized that I was the exception to the rule, as everyone around me relied heavily on their debuggers.

So what did I do when my program broke? Basically, I guessed. Usually when a bug happens it’s a direct consequence of something you changed in the very recent past, so that’s a good place to start looking. My analysis was never very detailed, basically just changing something back or slightly modifying something to see if this would fix or influence the problem. When my first instinct didn’t prove right, I’d either try more guesses or resort to a massive amount of printlns that output debug info while running the program normally. I’ve since learned a lot, and I try to avoid println statements wherever I can, and I think my skill as a programmer and the quality of my code improved after I made this step.

I still don’t do much debugging, although it does depend on which language I’m using. I blame perl for making me dislike debuggers. I never liked debugging perl. It was just way faster to guess-run-fix the problem than to figure out how to use the debugger. In Java I use the debugger in Eclipse, which is excellent. Still, I rarely ever need it, but during the times that I did need it I’ve realized the value of the debugger.

It’s quite easy to depend on it too much though. In a recent case I was developing for the iPhone and mixing Objective-C, C++ and C code, which confused the debugger a lot. And trying to fix a problem on an iPhone app without a debugger and in a crappy environment (XCode just plain sucks), it’s like trying to pick up a dime in the middle of a highway while wearing earplugs and eyeshades. At night.
Interestingly the XCode debugger, when switching from Obj-C/C to C++, messed up all data types, making it impossible to look at the values of anything: pointers, integers, ids, they’re all messed up. So how did I solve the problem I was having? Simple: I used printlns. Lots of them…

Viva la debugger!

1 Comment »

  1. you should try test driven development… you’ll code faster by writing unit tests first then writing the code to make the tests pass… it’s hard getting used to at the beginning but it’ll save u hours of debugging later.

    if you do TDD properly… you might never need to use a debugger

    Comment by bert — February 6, 2010 @ 22:15 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: