320 likes | 552 Views
Data Validation Tests. NumericAlphabeticReasonableness (limit or range)Consistency checkExisting Code. Sequence CheckCompleteness CheckData CheckSubscript CheckDefensive Programming. Numeric Test. Ensures that a numeric field contains numeric data, $ . Blanks are not numeric. Reasonablene
E N D
1. Chapter 8 - Data Validation
2. Data Validation Tests Numeric
Alphabetic
Reasonableness (limit or range)
Consistency check
Existing Code Sequence Check
Completeness Check
Data Check
Subscript Check
Defensive Programming
3. Numeric Test Ensures that a numeric field contains numeric data
, $ . Blanks are not numeric
4. Reasonableness Check A limit or range check
Ensures that a number is within expected limits, does not exceed an upper or lower extreme
5. Consistency check Verifies that the values in two or more fields are consistent
Example:
Individual’s credit rating and the amount of credit a bank is willing to extend
6. Existing Code Check Each code should be explicitly checked, just because you check one code doesn’t mean the other is right.
Example of bad code
If sex-in = “Male” Add 1 to Number-of-Men
Else
Add 1 to Number-of-Women
7. IF statement Has a large number of options
One of the most difficult statements to master
An IF requires a CONDITION to be evaluated TRUE or FALSE
8. Four Types of Conditions Relational
Class
Sign
Condition-Name
9. Relational Conditon Most Common Condition
Compares the quantities on both sides of the relational operator to be True or False
The data types being compared must be of the same type, both numeric or both nonnumeric
11. Class Test Ensures that a field contains numeric or alphabetic data in accordance with its PIC clause
Numeric fields = 0 to 9 and a sign (+, -)
Alphabetic = A to Z and/or blanks
Alphanumeric = letters, numbers, special characters
13. Sign Test Determines whether a numeric field is positive, negative, or zero.
You could use a relational test to check for the sign of a number
15. Condition-Name Test A special way of writing a relational condition that makes it easier to read
88-level entry in Data Division simplifies coding in Procedure Division
17. Compound Test Using two or more tests at a time with the AND or OR operators
AND implies all conditions must be TRUE
OR implies one condition must be TRUE
19. Hierarchy of Operations Which takes precedence in a nested IF?
Arithmetic expressions
Relational operators
NOT condition
AND (from left to right)
OR (from left to right)
20. Implied Conditions The simple conditions with a compound condition often have the same subject as the statement
If salary > 30000 and salary < 40000
If salary > 30000 and < 40000
If department = “MIS” or “ACC”
21. Nested IFs Results when either statement 1 or statement 2 is itself another IF statement, two or more Ifs in one sentence
25. Accept Statement Used to obtain the day, date, and/or time of execution