Debugging is a technique to find and resolve error. There are three main types of error that are Syntax error, Logic error, and Run-time error.
• Syntax error: A syntax error refers to a mistake in a statement’s syntax. It is a fatal error that the programmer must correct before being able to fully compile the program. They are indicated by the compilers while compiling the program. Some IDEs are able to display syntax errors in real-time.
• Logic Error: Logic Error is a kind of error which causes unexpected and different results than the kind of results for which the program has been made. These errors are not detected by the compilers. Logic errors are usually the hardest to debug because they do not cause the program to fail completely. A common technique in solving logic errors is to print the program’s variables to a file or the console in order to isolate where the problem is.
• Run-time Error: this error occurs during run time. These are exception errors. Example divides by zero.
Now the big question arises that how to Debug?
The basic steps in debugging are:
• Recognize that a bug exists
• Isolate the source of the bug
• Identify the cause of the bug
• Determine a fix for the bug
• Apply the fix and test it
• Walk through your program
• Display the variables at certain points, trace the program
• Use of professional debugger
Testing Methods (1):
White box (structural) testing:
It makes use of knowledge of how the program works, and its structure. White box testing uses an internal perspective of the system to design test cases based on internal structure. Here the tester needs to be an expert he chooses the various input paths but determine an ultimate output path.
Testing Methods (2):
Stepping through Code:
Modern debuggers usually allow you to step through your program and look at the values of variables. Also the debugger will allow you to set breakpoints, which are statements in your programs that you mark and tell the debugger to suspend program execution when it gets there.
Start, Stop, Break, Restart
Step Into: Executes the next statement even if it’s inside a new procedure
Step Out: Finishes executing the current procedure and stops when control returns to the calling procedure
Step Over: Executes the next statement. If that statement is a procedure, the procedure is executed without stopping
• Autos, Locals, Watch windows
• Call Stack window