Error Correction Techniques Program Code has bugs not
Error Correction Techniques “Program Code has bugs not errors. Debugging is the process of finding and fixing errors. ” Carole Wilson (SDD Prelim Course) p 130
Types of Coding Errors • Syntax Errors – Occur when the code does not match the rules of the language. - Examples include - typos such as wmile instead of while or using the wrong type of brackets or other symbols - Forgetting punctuation such as a ; or. - Leaving out part of a statement such as not including an ENDIF after an IF - These errors usually show up when a program is compiled before execution, and are sometimes called Compile Errors
Types of Coding Errors • Run Time Errors – Show up while the program is running – Can be a result of logic errors, overflow errors or undefined arithmetic operations – Some common run-time errors that will not show up during program compile include: • Mathmatical operations with non numeric data • Dividing by zero – Overflow errors usually occur when a calculation is performed on an incorrect data type and becomes impossible to store in the targeted memory location. Examples include: • Assigning variables to the wrong type real number as an integer • Array range errors where there are more variables in an array than have been declared
Types of Errors • Logic Errors – Often occur when implementing conditions or repetition – Can occur when assigning values to variables – Can be helpful to • refer to your pseudocode and compare it to your actual code • Include flags and step through your program while comparing expected and actual conditions and values
Debugging Tools • Stubs – Used to check connection between modules of code without the module of code existing – Let you test the main logic or flow of the program • Breakpoints – Lets the developer indicate where in a program they want it to stop during execution – Often the development environment will let you examine the value of variables as they were prior to hitting the breakpoint • Flags – A developer can introduce a flag to show a certain part of the code has been reached. – A flag is a boolean variable that the developer can tested within the code • Debugging Output Statements – A developer can make a program print messages to the screen while a program is running to show that a particular point in the program was reached. – A developer can also populate the display to show the value of a variable during program execution – Visual Basic offers tools that allow the developer to follow the contents of a variable during execution
- Slides: 5