2.3 Defensive Design and Testin Flashcards
OCR GCSE Computer Science J277
Data type check
Checks that the value entered is of the required data type
An age has been input as an integer, e.g. 21
Range check
Checks that the data is between an upper limit and a lower limit
A probability is between 0 and 1
Limit check
Used to check either the upper limit or the lower limit
The price of an item is not below the lower limit of 0.00
Length check
Checks that a specific number of characters or digits has been entered
A passport number is exactly 9 digits long
Format check
Used to check that the data is in a specified format. Regular expressions can be useful here to match a string against a pattern.
A date is in the format DD/MM/YYYY
Presence check
Checks that something has been entered into a field and the field has not been left blank
A ‘City’ field has not been left blank when a user is entering an address
Existence check
Used to check that a piece of data or the name of a file actually exists
The surname “Lau” exists in a customer record. The file name “highscores.csv” exists during file handling
Consistency check
Checks that pieces of data from two or more fields are compatible with each other
The number entered for the day of the month is not higher than 29 if the month chosen is February
Uniqueness check
Checks that a value entered is a new and original value
A username has not already been chosen when a user is creating a new account
Check digit
A digit that helps confirm that a code is correct
The last digit of a barcode is calculated from all of the numbers before it
Data Type
E.g. string, integer, character, float, Boolean. An attribute of a data item that determines the values that can be stored and the operations that can be carried out on the data item.
Casting
Changing the data type of a piece of data, for example converting a string to an integer
String
A sequence of characters, e.g. letters, numbers, spaces and other symbols
Integer
A whole number that is either positive or negative. Examples: 5, 14, -29
Float
A data type for a number with a decimal place. Stored as a floating point number.