SAM HARRIS TECH REVISION
OCR GCSE CS - 2.3 Producing Robust Programs
2.3 Producing Robust Programs (OCR J277)
2.3.1 Defensive Design
- Anticipating Misuse: Thinking about how a user might break the program and preventing it.
- Authentication: Confirming the identity of a user (e.g., passwords, biometrics) before allowing access.
- Input Validation: Checking if data is sensible before processing (e.g., Range check, Type check, Length check, Presence check, Format check).
- Maintainability: Writing code that is easy for others to understand and update using:
- Comments (# or //) to explain logic.
- Indentation to show code structure.
- Meaningful variable names (e.g., "score" instead of "s").
- Constants for values that don't change.
- Subprograms (functions/procedures) to avoid repetition.
2.3.2 Testing
- Purpose of Testing: To ensure the program works as expected and to find/fix logic and syntax errors.
- Iterative Testing: Testing modules of code as they are being developed.
- Final/Terminal Testing: Testing the complete program after development is finished.
- Test Data:
- Normal: Data the program should accept (e.g., 5 for a 1-10 range).
- Boundary: Data at the very edge of the limit (e.g., 1 or 10).
- Invalid: Data of the right type but outside the range (e.g., 15).
- Erroneous: Data of the wrong type (e.g., "hello" instead of a number).
Related Past Paper Questions
-
Year: 2024
Describe the purpose of 'Defensive Design' when developing a program.
Mark: [2]
-
Year: 2024
State the difference between 'Input Validation' and 'Input Sanitisation'.
Mark: [2]
-
Year: 2023
Explain how the use of 'Maintainability' features, such as comments and indentation, helps a programmer.
Mark: [3]
-
Year: 2023
Identify two types of errors that can occur in a program and describe each one.
Mark: [4]
-
Year: 2022
Describe the purpose of 'Iterative Testing' during the development of a program.
Mark: [2]
-
Year: 2022
A program expects a whole number between 1 and 10. Identify one piece of 'Boundary Data' and one piece of 'Invalid Data' for this program.
Mark: [2]
-
Year: 2021
Explain the difference between 'Final Testing' and 'Iterative Testing'.
Mark: [2]
-
Year: 2021
Identify three features of a program that make it more maintainable.
Mark: [3]
-
Year: 2020
A user enters 'twelve' when a program expects '12'. State the type of error that has occurred if the program crashes.
Mark: [1]
-
Year: Sample Paper
Describe how a 'Trace Table' can be used to identify errors in an algorithm.
Mark: [2]