Skip to content

Robust programs and testing

GCSE Computer Science revision notes, key terms and practice questions.

In short

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.

For GCSE students in Years 10 and 11, on the AQA, OCR, Edexcel and Eduqas Computer Science courses.

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.

Quick questions on Robust programs and testing

What does a range check do?
Checks that a value is between a lower and an upper limit: For example, a mark from 0 to 100.
Which check makes sure that a field is not left blank?
Presence check: It checks that something has been entered.
What is verification?
Checking data has been entered correctly, such as typing it twice: It catches typing mistakes.
What is authentication?
Checking that a user is who they say they are: Usernames and passwords are a common method.
A program is missing a closing bracket and won't run. What type of error is this?
Syntax error: It breaks the rules of the language.
A program runs, but it calculates the wrong total. What type of error is this?
Logic error: The code is valid, but the logic is wrong.
Valid ages are 11 to 18. Which of these is boundary data?
18: 18 is at the edge of the valid range.
Valid ages are 11 to 18. Which of these is erroneous data?
Twelve: It is text, not a number, so it should be rejected.

Robust programs and testing: questions and answers

What is normal test data?
Typical valid data that the program should accept. For example, 14 for ages 11 to 18.
Why do programmers write comments?
To explain the code so it is easier to maintain. Comments are ignored when the program runs.
What is iterative testing?
Testing during development, as each part is written. Final testing happens at the end.

Practise Robust programs and testing: 17 questions

Download these notes as a PDF

Previous topic: Subroutines and parametersNext topic: Binary, denary and hexadecimal

More in Programming

LycoLearn is still loading…

This can take a little longer on a busy school or home network. If nothing happens, try refreshing the page.

LycoLearn didn’t load properly

Part of it didn’t arrive. Try refreshing the page in a minute, or open LycoLearn in another browser.