Debugging:
There are three basic errors:
Try to approach debugging with a sprit of play. Your experience
convince you that given enough time you can figure out any error.
So give yourself time and start the program assignments early.
Syntax/compilation error
Error during compiling, prevents getting a compiled code. Modern
compilers indicate well the location of the error. Sometimes problems
with delineators such as semi-colons in C or brackets in C++ or Java are
not detected for many lines or at the end of the class definition or end
of the program. In the Bash scripting language missing do
or done can be big problem. The difficulty is that compiler
misses the error long pass where the missing delineator is required.
Run-time Exception error
When you get an error message while running the compiled code.
Java gives good error messages indicating the location of the error but
that might not be the location of the actual error. Some languages,
such as C seem to have only one type of error; Segmentation Fault,
or Fortran, index out of bounds.
Common Run-time Exception error:
Error message | Common Cause |
Null pointer exception | java: Never instantiated reference,
c: Never assigned pointer |
Out of memory | Infinite loop or recursion.
c++: Memory leak |
Index out of bounds | Check for loops or while bounds |
Deference error | java: Improper casting |
Divide by zero | Check arithmetic, maybe never set denominator
Some c-compiler initially sets memory to zero |
The art of debugging is essentially learning a table like the above, which helps you locate the error. If have any strange errors and discover the cause of the error please tell me about it so I can add it to the table.
Logical Error:
Theses errors are the hardest to correct or detect. The program
"runs" but the output is not correct.
Tools for Detecting and fixing logical error:
The industry is concerned with Verification and Validation:
As example suppose that the program is a calculator then you may partition data as:
Paths are the different routes the computer can take through the program.
If example: