Debuggers?

Over at Damon Cooper's blog, he's soliciting comments on the ultimate CF IDE.  What surprised me was the number of requests for a CF debugger.  CF Studio had one, way back in the day, and apparently people still miss it.

On a similar note, I've been doing a lot of Java development in Eclipse of late, and there's a heavy bent towards debugging in the JDT platform as well.  For example, F11 will debug the last launched app, while CTRL-F11 will just run it normally.  Seems like it should be just the opposite.

I've also gotten into a pissing contest with a New Atlanta representtive about the merits of debugging.  Paraphrasing here, but one comment was along the lines of "if you don't use a debugger, you're not a fully skilled developer". 

I personally haven't used a debugger since my CS 330 class down in Arizona, when we HAD to in order to complete an assignment.  I can say, with complete honesty, that I haven't missed them at all.  How's that, you say?  It's simple:

Unit testing and log4j, with an emphasis on the former.

Many checks you do with a debugger can be written as a unit test, which not only allows you to let the computer do most of the work, but it also lets you save the tests to be rerun later as part of a regression test suite.  Needless to say, this is a huge asset, as it can prevent the reoccurence of bugs, while an ad hoc debugging session is ethereal.

Unit tests aren't suitable for all situations, however, such as when you need to do some ad hoc examination of execution in order to pinpoint a bug.  This is where log4j (or whatever other logging package) comes in.  By allowing you put logging messages directly in you code and leave them there, you obviate the need to maintain breakpoints for your debugger.  Further, by allowing different loggers and log levels, you can very finely tune the output you'll get from your logging statements, something that's rather hard to do with breakpoints in a debugger.

Unit testing is something that hasn't really reached the level of acceptance in the CF community it deserves.  A large part of that, I think, is because the tooling isn't stellar, which is directly attributable to CF being a hard language to build good a unit testing framework.  The runtime nature of CF, while one of it's strongest assets as a RAD language, is also a weakness in this case.

Fortunately, with the CFLOG and CFTRACE tags, you can get some of the benefits of structured logging.  Or, if you're not afraid of a little Java, it's a snap to leverage log4j directly in your CF applications.

5 responses to “Debuggers?”

  1. Sean Corfield

    It's so good to hear someone else who doesn't see the value in step-thru debuggers! I haven't used a source level debugger for… um… ten years at least, maybe longer than that…

    Like you I found that using better test harnesses and, if necessary, instrumenting my code with logging (which can be externally configured on or off) meant I just stopped needing a debugger.

  2. Sean Corfield

    p.s. cfcUnit with the ant task makes for a great automated harness for running unit tests :)

  3. Terry Schmitt

    I rarely used Studio's debugger. Now I generally have some sort of debugger in my CF apps that I can enable to dump some key data and the CF errors. The one place that I really find a debugger useful is with JavaScript. This is where Firefox and Firebug rock!

  4. Ben Nadel

    I have not gotten into CFLog and CFTrace much (and have not worked on HUGE projects) but I come from the mentality of "code-a-bit, test-a-bit". I test things right when I build them and have a very methodical way of testing ranges of values in an attempt to break what I build. I don't know much about Unit testing but I think its basically a programatic way of doing what I do manually?

    But anyway, long and short of it is that I too do not feel the need for a debugger. As far as I am concerned CFDump pretty much solved most debugging problems I ever needed.

  5. Eric Laney

    I used the debugger constantly in the days of CF5, and I was heartstruck that ColdFusion MX didn't support it. I then had the opportunity to talk with the product manager for ColdFusion (both server and Studio). When I asked him about the possibility of a future debugger in ColdFusion MX, he simply said, "well, we found that there just weren't that many people using the debugger."

    Apparently, *I* was the one in the minority.