Developer's Toolkit

Blog archive

Testing is the New Debugging

I've gradually noticed that developers don't use debuggers much any more. It was a gradual sort of thing, even in my own occasional development activities. This got me to thinking about the shift we've experienced over the last several years to managed platforms, primarily Java and Microsoft .NET. They have changed a lot of behaviors, because most bugs in the past typically had something to do with memory allocations, references, and de-allocations.

(Of course, some of you might remember programming for DOS, when you also had to worry about small, medium, and large memory models, adding yet another layer of complexity to using and misusing memory).

Ten years ago, I spent possibly as much as half of my development time chasing down memory references. Today, I do occasionally think about the implications of my implementations on memory use, but I know things are going to work.

But even when they don't, I don't typically turn to a debugger. The debugger menu selection on my IDE remains ignored, even when I have problems getting something to work correctly. The debugger—which lets me set breakpoints, step through code line by line, and examine the value of variables—seems more and more like a sledgehammer attacking a thumbtack problem.

Instead, once I get something running, I'll write a quick unit test, and see what results it returns. From there, I might record code coverage to identify the code path used, and write a few more tests to narrow down the possible scope of the error. As a last resort, I might turn to the debugger to step through the code executed by a unit test to examine specific pieces of logic.

It's not that bugs have gone away with managed platforms. Instead, I've come to the conclusion that the debugger is simply less useful when the majority of your problems are logic errors, failure to consider a wide range of possible use cases, and flow-of-control errors. It's more useful to localize the error with small tests, collect information during these tests, and then drill down into that information to understand not only the error, but what led to it.

That is why I say that testing is the new debugging. The corollary of that is that any way to improve the process of writing and executing tests, evaluating the results, and collecting more detailed information during testing to enable the drill-down is an essential part of finding and diagnosing errors. There is still a role for traditional debugging, but it should take a back seat to an increased focus on testing. Managed platforms made a lot of coding practices more efficient, and testing can make debugging more efficient as well.

I talk about this topic in more detail in my column in the November issue of Java Pro.

Posted by Peter Varhol on 09/17/2004


comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube