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.
Function
A named block of code that performs a task and returns one or more values
Syntax
The precise way that program statements must be written to be understood by the computer. It is specific to the programming language in use.
Syntax error
When the translator does not recognise the keywords or commands entered. Common errors of this type include mistyping a keyword or missing out brackets.
Logic error
When code runs correctly but the program does not work as expected or produce the expected output.
Runtime error
When an error occurs during the use of the program. Common errors of this type include trying to divide by zero or accessing an item in an array that does not exist.
Testing
The systematic process of checking that a subroutine, program, or system works as expected
Test data
Data that has been carefully selected for testing. It should include normal, boundary and erroneous values as appropriate
Boundary data
Test data that is on the limit of the acceptable range of valid data
Erroneous data
Test data that should be caught by validation and rejected by a system