Error Correction Techniques

5,141 views

Published on

sdd software design and development error correction techniques.

Published in: Education, Business, Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
5,141
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
104
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Error Correction Techniques

  1. 1. Error Correction Techniques
  2. 2. Types of Coding Errors <ul><li>Syntax </li></ul><ul><li>Runtime </li></ul><ul><li>Logic </li></ul>
  3. 3. Syntax <ul><li>Syntax errors are written statements that do not conform to the rules of the language. The rules of the language are shown in metalanguages (BNF, EBNF or railroad diagrams) that describe the language. </li></ul><ul><li>Syntax errors can be caused by: </li></ul><ul><ul><li>typing mistakes in reserved words </li></ul></ul><ul><ul><li>missing or wrong punctuation </li></ul></ul><ul><ul><li>variable names which do not conform to the language rules </li></ul></ul><ul><ul><li>failing to complete groupings, e.g. IF but no END IF </li></ul></ul>
  4. 4. How many syntax errors can you find here?
  5. 5. Logic Errors <ul><li>Logic errors have occurred when incorrect algorithms result in unexpected output. Logic errors should be detected by desk checking the algorithm with carefully chosen test data. Peer checking by a colleague is another way to locate logic errors. </li></ul>
  6. 8. Run Time Errors <ul><li>Run-time errors cause a program to fail or crash after it has been compiled and executed. Run-time errors can be very difficult to locate. Run-time errors are located by running the program with a well-chosen range of test data. Beta version testing involves independent operators who try to find as many execution errors as possible. </li></ul><ul><li>Causes of run-time errors </li></ul><ul><ul><li>Common causes of run-time errors include: </li></ul></ul><ul><ul><li>attempting arithmetic calculations for which there is no result, e.g. dividing by zero, tan 90° </li></ul></ul><ul><ul><li>overflow, e.g. using integers too big to be stored in the allocated memory. So, on many machines, 32766 + 2 will result in an overflow error message or an unexpected negative number. </li></ul></ul><ul><ul><li>trying to access inappropriate memory locations, e.g. a non-existent array element array [10] in a 5 element array. </li></ul></ul>
  7. 9. You need to try and force the following errors in a program. What are the error messages that you got? Yay! Some practical!
  8. 10. How do we fix errors? <ul><li>Hopefully, before programming. </li></ul><ul><li>This is why we desk check algorithms for accuracy in logic before programming </li></ul><ul><li>The longer that an error remains undetected, the more expensive and time consuming it is to fix </li></ul><ul><ul><li>(eg, Millenium Bug) </li></ul></ul>
  9. 11. Stubs <ul><li>Used to check the connection between modules of code </li></ul><ul><li>Good programming uses subprograms or modules to perform single tasks. This is easier to debug, more conducive to a team approach and easier to maintain. To test whether all the modules will work together, before all the modules are coded, small modules can be created to represent parts of the program yet to be written. These are called stubs. Stubs may be used to: </li></ul>
  10. 12. Stubs <ul><li>Display a message that indicates that a particular section of the program has been reached. </li></ul><ul><li>In this example, stubs are used to test the menu module of a program </li></ul><ul><li>The menu consists of five choices: addition, subtraction, multiplication, division or exiting the program. </li></ul><ul><li>The procedures for adding, subtracting, multiplying and dividing have not yet been written. In this pseudocode algorithm, stubs displaying the option chosen replace them. This tests the logic of the algorithm. When coded and tested, the programmer will know that the menu is working by seeing the correct display. Code modules will replace the display stubs as they are written. </li></ul>
  11. 13. Flags <ul><li>Used to check if a section of code has been processed </li></ul><ul><li>In complex programs, it is sometimes helpful to know whether a certain condition has been met, (e.g. has a delete module been used), and to act on that condition later in the program. </li></ul><ul><li>A flag is a variable that is used to indicate whether an event has occurred or not. Flags are often Boolean variables set as false at the beginning of the program. Flags are particularly useful in program testing to determine whether a particular piece of code has been called. </li></ul>
  12. 14. Debugging statements <ul><li>Additional print statements in the code that help in telling what part of the code has been executed for the interrogating variable contents at a particular point in the program’s execution. </li></ul>

×