Robust and secure programming — AQA GCSE Computer Science
Robust and secure programming involves designing software that handles unexpected user inputs and runtime conditions without crashing, alongside protecting code against vulnerabilities. In AQA GCSE Computer Science, this centres on defensive design techniques including input validation, sanitisation, authentication, maintainability, and structured testing.
Robust and secure programming explained
To select suitable test data, first identify the input requirements and any validation rules from the problem.
Read the full explanation
Then choose data that covers three categories: normal data (valid, expected values), boundary data (values at the edges of valid ranges, such as the minimum, maximum, and just inside/outside limits), and erroneous data (invalid values that should be rejected). For example, if a program accepts an integer between 1 and 100, normal data could be 50, boundary data could be 1, 100, 0, and 101, and erroneous data could be 'abc' or -5. Justify each choice by explaining what it tests: normal data checks typical processing, boundary data checks the limits of validation, and erroneous data checks error handling. The justification should link the data to the specific rule or requirement it verifies, demonstrating understanding of robust programming.
Your focus
- Identify the input requirements and validation rules for a given problem.
- Select appropriate normal, boundary, and erroneous test data.
- Justify the choice of each test data item by linking it to the problem's requirements.
Robust and secure programming exam tips
Topic Overview
Robust and secure programming focuses on designing software that anticipates misuse, mitigates runtime faults, and guards against malicious attacks. Students learn how defensive design practices ensure programs fail gracefully or reject improper data rather than crashing.
This topic connects algorithmic problem-solving to real-world software engineering across AQA Paper 1. Understanding validation, sanitisation, authentication, maintainability, and rigorous testing equips students with the foundational skills needed to build dependable software architectures.
Key Concepts
- →Defensive design: Anticipating every route of user error, accidental misuse, and malicious exploit before writing functional logic.
- →Validation vs Sanitisation: Validation checks data against rules (e.g., presence, length, range, format, type); sanitisation cleans or strips unwanted characters before processing.
- →Authentication: Verifying the identity of a user before granting access to resources (e.g., passwords, biometric checks, multi-factor authentication).
- →Code maintainability: Techniques that make code readable and modifiable, such as meaningful variable names, code comments, modular subroutines, and consistent indentation.
- →Test strategies: Differentiating between iterative testing (conducted during development) and final/terminal testing (conducted at the end of development against original requirements).
Marking Points
- Select normal data that is valid and within the expected range to test typical processing.
- Select boundary data at the lower and upper limits of valid input, and just outside those limits, to test validation edges.
- Select erroneous data that is invalid, such as wrong data type or out-of-range values, to test error handling.
- Justify each test data choice by explaining which requirement or validation rule it checks.
- Ensure the test data covers all relevant input conditions for the given problem.
- Use the problem's specification to determine appropriate values, rather than choosing arbitrary data.
Examiner Tips
- 💡Read the problem carefully to identify all input constraints, such as ranges, data types, and required formats.
- 💡Use a table to organise test data with columns for data, type (normal/boundary/erroneous), and justification.
- 💡For boundary data, include values just inside and just outside the valid range, as these are most likely to reveal off-by-one errors.
- 💡When justifying, state what the program should do with that data, e.g., accept it, reject it, or produce a specific output.
- 💡When naming validation checks, use the exact standard curriculum terms: range check, length check, type check, format check, presence check, or lookup check.
- 💡In test table questions, always provide an expected result alongside your sample input (e.g., Input: 12, Expected: Error message displayed).
- 💡When explaining maintainability, state both the method (e.g., modularisation) and the direct human impact (e.g., makes debugging faster because code blocks can be tested independently).
Common Mistakes
- Selecting only normal data and ignoring boundary and erroneous cases, which leaves validation untested.
- Choosing boundary data that is not actually at the limit, such as using 10 when the range is 1-100.
- Failing to justify the choice, or giving a justification that does not link the data to a specific rule or expected outcome.
- Believing authentication and validation are the same: Validation confirms data conforms to structural rules; authentication verifies that a user actually is who they claim to be.
- Assuming boundary data means extreme values: Students often provide massive values like 999999 instead of values sitting directly on the valid/invalid boundary edges (e.g., 0 and 1 for min limit 1).
- Thinking comments and indentation affect machine execution speed: Comments and whitespace are stripped during compilation or interpretation and have no bearing on machine run-time efficiency, but are vital for human maintainability.
Revision Plan
- 1Day 1-2: Master defensive design theory; create flashcards defining the six validation check types and input sanitisation.
- 2Day 3-4: Practice writing Python or pseudocode scripts implementing `try...except` exception handling and validation loops.
- 3Day 5: Revise test plans by drawing test tables and populating them with normal, boundary, and erroneous data for past paper prompts.
- 4Day 6-7: Complete timed AQA Paper 1 past paper questions focused on code maintainability and defensive programming.
Exam Question Types
- 📋Test Data Tables: Completing a 4-column table (Test Type, Test Data, Purpose, Expected Result) for a given algorithm snippet.
- 📋Code Correction/Refactoring: Identifying why an unvalidated script would crash and rewriting it to handle bad input robustly.
- 📋Maintainability Evaluations: Explaining two or three ways a poorly written script can be made easier for a team of developers to maintain.
Command Word Expectations (AQA)
Set out the causes, reasons, or mechanisms clearly. Mention the technique and link it directly to why it prevents failure or aids developers (e.g., 'Technique X does Y, which means Z happens').
Provide a factual name or brief term without detailed narrative. For example, naming 'Range check' or providing a valid test value like '18'.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A program asks a user to enter their age to join an online gaming club. The age must be an integer between 13 and 18 inclusive. State two validation checks that should be applied to this input, and provide an example of normal, boundary, and erroneous test data for this system.
- 1.Step 1: Identify required validation checks suitable for the input criteria. The input must be a whole number, so a type check is required. The value must fall between 13 and 18, so a range check is required.
- 2.Step 2: Define normal test data. Normal data is valid data within the allowed range that tests standard execution. Suitable example: 15.
- 3.Step 3: Define boundary test data. Boundary data sits at the extreme ends of the accepted limits. Suitable examples: 13 (lower boundary) or 18 (upper boundary).
- 4.Step 4: Define erroneous (invalid) test data. Erroneous data violates the validation rules and should be rejected. Suitable examples: 12 (below range), 19 (above range), or 'fourteen' (incorrect data type).
Question: Explain two programming practices that improve the maintainability of source code for future developers.
- 1.Step 1: Identify the first programming practice that aids human readability and comprehension. Meaningful identifier names for variables, constants, and subroutines.
- 2.Step 2: Explain the direct benefit of meaningful identifiers. Using descriptive names like 'totalScore' instead of 'x' allows future programmers to understand the purpose of each variable without reverse-engineering the code.
- 3.Step 3: Identify the second programming practice. Modularisation through subroutines (functions and procedures) or indentation/comments.
- 4.Step 4: Explain the benefit of subroutines/comments. Comments explain complex logic, while subroutines break code into self-contained blocks, making individual components easier to test, update, and reuse without unintended side effects.