Chapter 11. Data Validation

AVOIDING LOGIC ERRORS BY VALIDATING INPUT

Everyone is aware of horror stories resulting from computer errors. Newspapers often provide accounts of people who erroneously receive computerized bills or checks for absurd amounts. Although the blame is usually placed on the computer itself, such problems almost always occur because of either program errors or input errors. Debugging a program means eliminating all types of errors.

In Chapter 5 we discussed in detail program errors and methods used to eliminate them. Program errors fall into two categories: syntax errors and logic errors. Syntax errors are listed by the compiler and must typically be corrected before a program can be executed. These consist primarily of rule violations.

Logic errors are more difficult to find. They are not detected during compilation. They can be tested only when the program is run with test data. If the results of the run are inaccurate, then a logic error has occurred.

These may result from using the wrong instruction or the wrong sequence of instructions. Logic errors also include run-time errors, which cause program interrupts. Attempting to divide by a field that contains a zero, for example, will cause a run-time error. To eliminate logic errors, the programmer must develop comprehensive test data that includes all conditions and types of data tested for in the program. The programmer must also be very careful to manually check computer-produced results for accuracy.

Tip ...

Get COBOL for the 21st Century now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.