The Many Phases of Debugging

Nearly every time developers open the IDE, they are in some way debugging their code. The line between debugging and writing code, in fact, is blurred. For example, the code editor helps eliminate errors in your code as you write it. It highlights items where errors are present and enables you to fix them. You are then both writing and debugging simultaneously.

In addition, the compiler acts as another debugging tool. It is constantly compiling your code and checking it. Should you click the Run button, the compiler will report a list of errors for you to fix before continuing. This is debugging. The steps or phases of the debugging process include the following:

Image Coding—The editor helps you by pointing out issues and possible resolutions using the Quick Actions menu (light bulb) and other visual cues.

Image Compiling—The compiler checks your code and reports errors you should fix before continuing.

Image Self-checking—You run the application in debug mode and step through screens and code to verify functionality.

Image Unit testing—You write and run unit tests to check your application. (See Chapter 8, “Testing Code.”)

Image Code analysis—You run the Static Code Analyzer to verify that your application meets project standards.

Image Code review—Your code is reviewed by a peer and issues are logged, tracked, and fixed accordingly.

Image Responding to bug—When a bug has been logged against the code, you must re-create and debug a specific scenario.

In this chapter, we concentrate on two of these phases: self-checking (which may include unit testing) and responding to bugs. These are the two phases in which developers get the most use of the debugging tools built in to Visual Studio. For the purposes of this chapter, we assume that the code is written and that it compiles. Let’s start by looking at how to self-check the code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset