DEBUGGING
Finding error, reasons of their occurrence and technique of their fixation.
Error and Exception
- Errors and exceptions, both interrupts the program execution.
- Errors and exception are not same.
- Error, usually finds out at the time of translation.
- whereas, exception generates during program run, due to an input.
- An error is also known as bug,is a programming code that prevents a program from its successful interpretation.
Error are of three type:
- Compile time error
- Run time error
- Logical error
- Compile time error
- Syntax error: Violation of formal rules of a programming language results in syntax error.
x=(x*y)
- semantics error: semantics refer to the set of rules which sets the meaning of statements.Meaning less.
- Logical error
If a program is not showing any compile time error or run time error but not producing deride output, it may be possible that program is having a logical error. This error generates because of wrong analysis by programmer.
For ex. To use a variable without an initial value.
- Run time error
These errors generates during a program execution and known as run time error.
some run time error are difficult to find out.
some error prevent a program from execution which is known as program crash or abnormal fermentation of program.
EXCEPTION
- Exception is a state when a program turminance abnormally unit cant't be controlled.
b=0
(=a/b(Mathematics exception)
An uncertain cause termination of a program.
Exception handling in python
- Try and except claim are used to handle an exception.
# Code with probability of exception will be written here.
Except
# Code to handle exception will be written here.
Hoe to debug a program?
An error can debugged by correcting the code.
There are following techniques of debugging.
- To identify the place of error generation.
- By tracing the program code.
Detection origin of an error
When you run a code interrupt will run a line of code if it is free from any syntax and semantics error. And will visit the error if the running line of code has some error.
Printing of step wise value of variable
Depending upon your algorithm the variable value change during the execution some times we get incorrect output but cannot figure out what is causing it, in that case it is good idea to add many inspect values of variables after each step.
Tracing of code
Code tracing means executing code one line at a time and watching it's impact on variable, it is often done with butin debugging tools also known as debugger.
Break Point
Break point are temporary halt maker in source code that stop the debugger at the marked code line by line from top to bottom and half at the where the break point is setup.
No comments:
Post a Comment