Debugging process considered harmful


The following is a result of personal experience on a number of projects:


* First of all, in general, you cannot install the debugger where the application you are developping will ultimately run. If you are writing a desktop application, there is no way you will be able to install a decent debugger there. If you are writing a server application, the operation team will probably not let you install the debugger of your choice on production servers! If you are lucky, you will be able to install a simplified debugger, like WinDbg that has almost no side effect. WinDbg just works for unmanaged code so far. I do not know any good standalone .Net debugger yet (w/o installing Visual Studio, that is). This is a real issue. If you have put all your debugging efforts in the Visual Studio debugger, putting your application in production is like sending a spaceship towards Mars without any communication with the ship: welcome to the unknown.


* Now, let’s get back to the development phase. You have to think that, when someone debugs, he just works for himself. Debugging may only be benefitial to one person. There is no way to transfer the work he has done (setting breakpoints, stepping into code, …) and the knowledge he has acquired on the program he was debugging (if any…) to someone else.
In a team development mode, the time spent by one individual on debugging is simply lost for the rest of the team.


* When someone debugs, he just does the same things (stepping) over an over agin, loosing precious time. He is just exchanging development (creativity) time with stupid “stepping” time. This is actually depending on the competency of the guy. A good developer will use good watches, good breakpoints and advanced debugging techniques. He will therefore loose less time than a beginner developer. Thus the next point:


* To debug efficiently, a developer needs to master a debugger, or worse a certain number of debuggers. Debuggers do not follow any real standards, beside some de facto common UI. Training should be required to be able to debug efficiently.


* If you manage developers and just take a look at the time the average developer in your team spends in the debugger, you should do something! But you can’t because Debugging trainings are very very rare and Debugging books are very rare too. Here are two decent books about debugging http://www.amazon.com/exec/obidos/tg/detail/-/0735615365/ and http://www.amazon.com/exec/obidos/tg/detail/-/1590590503 (not only for vb.net)



This explains why I almost never debug. And I think my productivity is greatly enhanced. I trace everything. I agree this is not ideal (some call it “printf debugging”…), but that’s just because no technical progress has been made in this domain. Today, putting traces everywhere is really prehistoric work. But that does not mean traces are bad, it just means nothing is there to help us add traces automatically to our code. I would like to be able to tell to the C# compiler: “put traces here and here, please remember the values of the parameters automatically, just like you do when I debug. Please add a hierarchical trace of this object, and please record all that that so I can replay it later, add filters, and so on…”. That service should be provided by the CLR, IMHO.


Comments (10)

  1. Jesse Ezell says:

    Yes, NUnit is how you SHOULD address these issues. Trace statements don’t tell you what is broken, a properly designed test suite will.

    However, when it comes to tracking down a specific bug, then the debugger is invaluble. In VS.NET, it is drop dead easy to use and doesn’t really take much training, if any. Debuggers aren’t even meant to be used with production code, they are meant to be used in the developement phase, so you shouldn’t ever attach to your live servers. With VS.NET, you can use remote debugging, but you should attach to a staging server, not your live servers. This staging server should duplicate the configuration of your live server, so you should almost never run into any issues that come up only once you have deployed to your live server.

    In any case, you really should start using the debugger.

  2. Anonymous says:

    Frans Bouma’s blog

  3. Anonymous says:

    Fabrice’s weblog

  4. Anonymous says:

    SBC DotNet Weblog

  5. Anonymous says:

    Simon Mourier’s WebLog

  6. The thing is: I have no need for a debugger. I think debugging is a total waste of time for me(don’t flame me ;-), and also when I look at people when they debug. I am very happy to trace things. I am just missing good tracing support from the CLR and/or Visual Studio. It needs to be builtin.

    For example, how can you get the values of the parameters on the stack programmatically? You can get the stack, the methods, lines, IL offset and all that, but what about the values?

    The ContextBoundObject trick is really a trick and since you can only derive from one class, it is not a good solution. There may be some delegator hacks / tricks also, but I think all this should be provided natively.

    I think NUnit is more for testing, and Log4Net is cool but another extra (huge) stuff to learn.