📁 Paper 1 · 3.2 Programming
3.2.11b Robust & Secure Programming
AQA 8525 · GCSE Computer Science · ~12 min read
Notes
──
Video
──
Worksheet
──
Quiz

Robust Programs

A robust program works correctly across a wide range of inputs, including unexpected or invalid ones, and handles errors gracefully without crashing. Robustness is achieved through input validation, error handling (exception handling), and thorough testing.

Input Validation

Validation checks that data entered by a user is acceptable — within the right range, type, and format — before the program uses it. It does not check whether data is true (that is verification).

Types of validation

Validation typeWhat it checksExample
Range checkValue is within permitted limitsAge between 0 and 120
Type checkData is the correct data typeScore must be an integer
Presence checkA required field is not emptyName field cannot be blank
Length checkString is the right lengthPIN must be exactly 4 digits
Format checkData matches a required patternDate is DD/MM/YYYY

Validation in AQA pseudo-code

SUBROUTINE getValidAge() REPEAT age ← int(INPUT("Enter age (0–120): ")) IF age < 0 OR age > 120 THEN OUTPUT "Invalid! Age must be between 0 and 120." ENDIF UNTIL age >= 0 AND age <= 120 RETURN age ENDSUBROUTINE

Authentication

Authentication is the process of verifying the identity of a user. It ensures only authorised users can access a system.

MethodDescriptionExample
Username & passwordUser knows a secretLogin to a website
BiometricsUser's physical featureFingerprint, Face ID
Two-factor (2FA)Two separate checks combinedPassword + SMS code
SUBROUTINE login() attempts ← 0 REPEAT user ← INPUT("Username: ") pass ← INPUT("Password: ") attempts ← attempts + 1 IF user == "admin" AND pass == "s3cr3t" THEN OUTPUT "Access granted" RETURN True ELSE OUTPUT "Incorrect credentials. Try " + str(3 - attempts) + " more time(s)." ENDIF UNTIL attempts >= 3 OUTPUT "Account locked." RETURN False ENDSUBROUTINE

Testing

Testing is checking that a program behaves correctly. Good testing uses a range of test data covering all categories of input.

Test data typeDescriptionExample (age 0–120)
NormalTypical, expected input within range25, 40, 70
BoundaryValues at the edge of the valid range0, 1, 119, 120
ErroneousInvalid data the program should reject-1, 121, "hello", 200

Why test at boundaries?

Most programming errors occur at the boundary — e.g., using < instead of <= means the boundary value (120) is incorrectly rejected. Always test both sides of a boundary.

Types of Testing

TypeWhen?What is tested?
Iterative testingDuring developmentEach module/subroutine as it is written
Final (terminal) testingAfter all modules are completeWhole program, end-to-end
Exam tip: For a "give examples of test data" question, always include normal, boundary, and erroneous data. State the expected result for each. AQA exams regularly give you a specific input range and ask for all three types.
⚠️ Common Mistakes
  • Confusing validation (checking data is acceptable) with verification (checking data is correct/true)
  • Forgetting boundary testing — testing 0 and 120 as well as -1 and 121 for a 0–120 range
  • Confusing authentication (proving who you are) with authorisation (what you're allowed to do)
  • Testing only normal data — erroneous data is where bugs most often hide
Video coming soon

Key points

  • Robust programs handle invalid input gracefully using validation loops
  • Five validation types: range, type, presence, length, format
  • Authentication = who you are; use REPEAT loops with attempt limits
  • Test data must include normal, boundary, and erroneous examples
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.2.11b Robust & Secure Programming

8 questions · 22 marks

Q1State what is meant by validation and give one example.[2]
✅ Mark scheme
Mark scheme
Validation is checking that data entered is acceptable / within allowed limits / in the correct format [1]; any suitable example e.g. a range check to ensure age is between 0 and 120 [1].
Q2State three types of validation check and describe what each checks.[3]
✅ Mark scheme
Mark scheme
Any three from (one mark each): range check — value is within permitted limits [1]; type check — data is the correct data type [1]; presence check — field is not left empty [1]; length check — string is the required length [1]; format check — data matches a required pattern [1].
Q3Write validation code in AQA pseudo-code for a score that must be between 0 and 100 inclusive.[3]
✅ Mark scheme
Mark scheme
REPEAT [1]; score ← int(INPUT(...)); IF score < 0 OR score > 100 THEN OUTPUT error message ENDIF [1]; UNTIL score >= 0 AND score <= 100 [1].
Q4Explain the difference between validation and verification.[2]
✅ Mark scheme
Mark scheme
Validation checks that data is acceptable/in the correct format/within range [1]; verification checks that data entered is the same as the original (e.g. re-entering a password to confirm it was typed correctly) [1].
Q5Give three categories of test data for a program that accepts a PIN of exactly 4 digits (1000–9999). State one example value for each.[3]
✅ Mark scheme
Mark scheme
Normal — e.g. 1234 or 5678 (expected to be accepted) [1]; boundary — e.g. 1000 or 9999 (at the edge, expected to be accepted) [1]; erroneous — e.g. 999, 10000, or "abcd" (expected to be rejected) [1].
Q6What is authentication? Give two methods of authentication.[3]
✅ Mark scheme
Mark scheme
Authentication is the process of verifying/proving the identity of a user before allowing access [1]; any two methods: username and password [1]; biometrics (e.g. fingerprint / face recognition) [1]; two-factor authentication [1] (max 2 from methods).
Q7State the difference between iterative testing and final testing.[2]
✅ Mark scheme
Mark scheme
Iterative testing happens during development — each module or subroutine is tested as it is written [1]; final (terminal) testing happens after all development is complete — the whole program is tested end-to-end [1].
Q8Why is boundary testing important? Give an example of a common boundary-related bug.[4]
✅ Mark scheme
Mark scheme
Most bugs occur at the boundary of valid/invalid ranges [1]; the boundary values themselves (e.g. 0 and 120) may be handled incorrectly by an off-by-one error [1]; example: using IF age < 120 THEN instead of IF age <= 120 THEN means 120 is incorrectly rejected [1]; testing boundary values (0, 1, 119, 120) would reveal this bug [1].
Check your answers above.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 7
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.2.11b Robust Programming

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.2.11a Structured Programming
23 of 57 · AQA 8525
3.3.1 Number Bases →