6 exam-style questions with full mark schemes and model answers. Write your own answer and the AI examiner marks it against the mark scheme.
Learn this properly: Defensive Design PrinciplesA program asks a user to enter their age, which must be a whole number between 0 and 120. The program will be used by many people, so the developer wants it to be robust.
Discuss how defensive design techniques — including input validation and anticipating misuse — could be used to make this program robust. You should refer to the types of invalid input the program might receive and how each could be handled. (6 marks)
A program accepts a test score that must be a whole number from 0 to 100 inclusive. The developer must test the input validation thoroughly using normal, boundary and erroneous (invalid) test data.
(a) Give one example of normal test data and explain why it is normal. (1 mark)
(b) Give one example of boundary test data and one example of erroneous (invalid) test data, explaining your choice in each case. (3 marks)
When writing and testing programs, three types of error can occur: syntax errors, logic errors and runtime errors.
(a) State what is meant by a syntax error and give one example. (2 marks)
(b) Explain why a logic error can be harder to find than a syntax error. (1 mark)
Maintainability is one of the principles of producing robust programs. Writing maintainable code makes a program easier for other programmers to understand and change in the future.
Describe two techniques a programmer could use to make their code more maintainable, and explain how one of them helps. (3 marks)
A developer uses both iterative testing and final (terminal) testing when building a program.
Describe the difference between iterative testing and final (terminal) testing. (2 marks)
A program is meant to calculate the average of three numbers, but it always gives an answer that is too large. The program runs without crashing and produces no error message, but the result is wrong.
State the type of error that is most likely present in this program. (1 mark)