Sunday, May 22, 2011

Debugging

Before going to explain debugging, I want to discuss, what a program means. As every computer student knows, a program is a sequence of instructions that specifies how to perform a computation. Computation can be mathematical or symbolic. Symbolic computation means computations like searching and replacing text in a document. Usually a program may have instructions to get input, display input, mathematical operations, conditional operations and iterative operations.

There can be chances to occur errors in the programs. Those errors are called as bugs. Tracking and solving those bugs is called as debugging. Debugging is one of the most intellectually rich, challenging, and interesting parts of programming. There is a classification regarding the type of errors.
  • Syntax errors
  • Runtime errors
  • Semantic errors
Syntax error occurs when the programmer violates the syntax of code. Syntax refers to the structure of a program and the rules about that structure. Python displays a message if a syntax error occurs.

Eg : (1+4) is correct but 1+4) is a syntax error.

Runtime errors cannot be seen until program execution starts. It usually indicates that something exceptional has happened. So it is also called as exceptions.

If a Semantic error occurs, the computer will not generate any error messages.  But the program will do something different than it is supposed to do. This error occurs due to the logical mistake of the programmer.

Debugging is also like an experimental science. Once you have an idea about what is going wrong, you modify your program and try again. If your hypothesis was correct, then you can predict the result of the modification, and you take a step closer to a working program. If your hypothesis was wrong, you have to come up with a new one. Programming is the process of gradually debugging a program until it does what you want.

Thanks

AJAY

No comments:

Post a Comment