Debugging

In software development, debugging involves locating and correcting code errors in a computer program. Debugging is part of the software testing process and is an integral part of the entire software development lifecycle (SDLC). The debugging process starts as soon as code is written and continues in successive stages as code is combined with other units of programming to form a software product. The debugging process can be made easier by using strategies such as unit tests, code reviews as well as debugging tools embedded in code editors such as the VS IDE.

The need to debug can occur at any level. At Compile time or Run time. With the use of intellisense in the VS IDE many compile time issues can be caught immediately as your coding and resolved. The more difficult issues usually occur during run time. And there are 2 areas of run time errors. Each requires it’s own way to approach.

  • Errors that cause the application to break.
  • Logic errors, where the application does not stop but the results are not what is expected.

Debugging tools can be found in most software development applications.

In VS the use of Visual Studio Debugger is an invaluable resource. With it you run your app in debug mode do all of the following:

  • Set breakpoints
  • Navigate and step through code using step commands
  • Step over code to skip functions
  • Step into a property
  • Run to a point in your code quickly using the mouse
  • Run to a cursor (sets temporary breakpoint on current line)
  • In some cases ‘edit’ code on the fly to continue debugging
  • Inspect variables
  • Examine the call stack
  • etc…

There are as many ways to approach debugging as there are developers. Early in my career I came to realize that debugging skills are vital to doing a great job so I searched until I found what I thought was the most comprehensive way to debug any issues that may arise. I combined these ideas and wrote them down, then I found this diagram that was created by Duncan Riach (Hackernoon.com). By following some or all of these steps the vast majority of bugs can be resolved relatively quickly.

Bugs can occur at any point in the development stack. On the client side, within the business logic layer (BLL), data access layer (DAL), on the server, on a client machine (configuration), it can even be a bug caused by how the user interacts with the application.

By following the above steps most all issues can be resolved in a relatively short period of time.


Debugging tools are a part of most software packages.

Visual Studio

  • Visual Studio Debugger
  • Intellisense
  • Exception Handling
  • Logging (Log4Net, database logging..etc)

Below is a ‘simple‘ example of a run-time bug / issue identified by the user of the application. The user is entering search criteria, but no results are being returned. The user knows that there should be search results.

Client Side (JavaScript, jQuery, Ajax)

  • Intellisense
  • Developer Tools (Chrome, Firefox, IE etc..)
  • Fiddler

Database

  • SQL Server Profiler
  • Debugger (Breakpoints, step into and over code)