Defensive design
- Anticipate misuse: think about the mistakes and mischief users might try, and plan for them.
- Authentication checks that users are who they say they are, for example with a username and password.
- Validation checks that data is sensible before it is used: a range check (between 1 and 100), a type check (a number), a length check (at least 8 characters), a presence check (not left blank) or a format check (matches a pattern, such as a postcode).
- Verification checks that data was entered correctly, for example by typing a new password twice.
Maintainability
- Make code easy to understand and update: use comments, meaningful names, indentation, subroutines and constants.
Errors
- A syntax error breaks the rules of the language, such as a missing bracket, so the program won't run.
- A logic error lets the program run, but it gives the wrong result, such as using < instead of <=.
- A runtime error happens while the program runs, such as dividing by zero.
Testing
- Iterative testing happens during development, as each part is written. Final (terminal) testing happens once the program is complete.
- Test data: normal data (typical values that should be accepted), boundary data (values at the edge of the valid range, and just outside it) and erroneous or invalid data (values that should be rejected).
- For valid ages 11 to 18: normal 14; boundary 11 and 18 (and 10 and 19 just outside); erroneous 'ten' or −5.
- A test plan lists each test, its test data, the expected result and the actual result.
Key terms
- Validation
- Checking that data is sensible and allowed before it is used.
- Verification
- Checking that data has been entered correctly, such as by typing it twice.
- Authentication
- Checking that a user is who they claim to be.
- Syntax error
- An error that breaks the rules of the language, so the code won't run.
- Logic error
- An error that lets the program run but gives the wrong result.
- Normal data
- Typical, valid data that the program should accept.
- Boundary data
- Data at the edge of the valid range, or just outside it.
- Erroneous data
- Data that is wrong and should be rejected.
- Test plan
- A list of tests with the data, the expected result and the actual result.