error correction techniques

14
+ Error Correction Techniques

Upload: kelly-bauer

Post on 17-May-2015

4.238 views

Category:

Education


0 download

DESCRIPTION

sdd software design and development error correction techniques.

TRANSCRIPT

Page 1: Error Correction Techniques

+

Error Correction Techniques

Page 2: Error Correction Techniques

+Types of Coding Errors

Syntax

Runtime

Logic

Page 3: Error Correction Techniques

+Syntax

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.

Syntax errors can be caused by: typing mistakes in reserved words missing or wrong punctuation variable names which do not conform to the language

rules failing to complete groupings, e.g. IF but no END IF

Page 4: Error Correction Techniques

+How many syntax errors can you find here?

Page 5: Error Correction Techniques

+Logic Errors

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.

Page 6: Error Correction Techniques

+

Page 7: Error Correction Techniques

+

Page 8: Error Correction Techniques

+Run Time Errors

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.

Causes of run-time errors Common causes of run-time errors include: attempting arithmetic calculations for which there is no result,

e.g. dividing by zero, tan 90° 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.

trying to access inappropriate memory locations, e.g. a non-existent array element array [10] in a 5 element array.

Page 9: Error Correction Techniques

You need to try and force the following errors in a program. What are the error messages that you got? Yay! Some practical!

Page 10: Error Correction Techniques

+How do we fix errors?

Hopefully, before programming.

This is why we desk check algorithms for accuracy in logic before programming

The longer that an error remains undetected, the more expensive and time consuming it is to fix (eg, Millenium Bug)

Page 11: Error Correction Techniques

+Stubs

Used to check the connection between modules of code

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:

Page 12: Error Correction Techniques

+Stubs

Display a message that indicates that a particular section of the program has been reached.

In this example, stubs are used to test the menu module of a program

The menu consists of five choices: addition, subtraction, multiplication, division or exiting the program.

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.

Page 13: Error Correction Techniques

+Flags

Used to check if a section of code has been processed

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.

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.

Page 14: Error Correction Techniques

+Debugging statements

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.