Appendix D Visual Studio .NET Debugger 1313 (Free web hosting music) Testing
Appendix D Visual Studio .NET Debugger 1313 Testing and Debugging Tip D.1 After fixing one error, you may observe that the number of overall errors perceived by the compiler is significantly reduced. Testing and Debugging Tip D.2 When the compiler reports a syntax error on a particular line, check that line for the syntax error. If the error is not on that line, check the preceding few lines of code for the cause of the syntax error. Debugging is the process of finding and correcting logic errors in applications. Logic errors are more subtle than syntax errors because a program that includes a logic error compiles successfully but does not run as expected. Logic errors often are difficult to debug, because the programmer cannot see the code as it executes. One strategy that novice programmers often use to debug programs is to display program data directly, using message boxes or Console.WriteLine statements. For example, the programmer might print the value of a variable when its value changes to determine whether the variable is assigned the correct value. This approach is cumbersome, because programmers must insert a line of code wherever they suspect there might be a problem. Furthermore, once the program has been debugged, the programmer then must remove the extraneous statements, which often can be difficult to distinguish from the original program code. A debugger is software that allows a programmer to analyze program data and trace the flow of program execution while the application runs. A debugger provides capabilities that allow the programmer to suspend program execution, examine and modify variables, call methods without changing the program code and more. In this appendix, we introduce the Visual Studio .NET debugger and several of its debugging tools. [Note: A program must successfully compile before it can be used in the debugger.] D.2 Breakpoints Breakpoints are a simple but effective debugging tool. A breakpoint is a marker that a programmer places in a code listing. When a program reaches a breakpoint, execution pauses this allows the programmer to examine the state of the program and ensure that it is working as expected. Figure D.2 is a program that outputs the value of ten factorial (10!)1, but contains two logic errors the first iteration of the loop multiplies x by 10 instead of multiplying xby 9, and the result of the factorial calculation is multiplied by 0(so the result is always 0). We use this program to demonstrate Visual Studio .NET s debugging abilities using its breakpoint capabilities as our first example. 1 // Fig. D.2: DebugExample.cs 2 // Sample program to debug. 3 4 using System; 5 Fig. D.2 Fig. D.Fig.Fi D.2g. D.22Debug sample program. (Part 1 of 2.) Fig. D. 1. The factorial of x(x!) is defined as the product of all digits less than or equal to xbut greater than zero. For example, 10! = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.