Community resourceWorksheet
J277 2.3 Producing robust programs consolidation
Part 7 of 7 · J277 2.3 · Producing robust programs
The consolidation worksheet for OCR J277 2.3, taking one festival booking system through validation, maintainability, testing and refinement.
Students will:
- implement a focused validation rule in Python
- improve the maintainability of supplied code
- find and refine a logic error
- select test data for the stated rules
- answer as feature, mechanism, then effect in this system
Inside: 5 explanation cells, 2 runnable Python tasks, 1 multiple-choice question, 1 fill-in-the-blanks cell and 5 written answers. 34 marks, about 60 minutes.
Series: J277 2.3 · Producing robust programs, part 7 of 7.
Shared by Coding PathwayVerified teacher
- 14 cells
- About 60 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
- Updated 9 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Producing robust programs: consolidation
This worksheet brings together defensive design, validation, authentication, maintainability, testing, error identification and refinement.
Use the early tasks to identify gaps, then complete the applied tasks and final evaluation independently.
The context is a school festival booking system. A user signs in, chooses an event code and requests from 1 to 6 tickets. The accepted event codes are MUSIC, DRAMA and CODE. A robust solution must reject unsuitable values, remain understandable for future programmers and be tested with deliberately selected data.
For longer answers, use a clear chain:
feature or problem, how it works, effect in this festival system.
Which action authenticates a festival organiser?
- ACheck that a ticket quantity is from 1 to 6
- BTest the completed system before release
- CCompare entered sign-in details with stored details
- DRename a variable so its purpose is clear
- defensive
- validation
- authentication
- iterative
- final
- boundary
- maintainability
Describe two defensive design measures for the festival booking system.
For each measure, name it and apply it to a specific input, identity check or likely misuse in this system.
Students type their answer here.
Implement one focused validation rule
Complete booking_is_valid(event_code, ticket_count). It must return True only when the event code is one of MUSIC, DRAMA or CODE and the ticket count is from 1 to 6 inclusive.
The function receives both values as parameters. Do not ask for new input inside it. The checks will test accepted codes, unknown codes and both ticket boundaries.
def booking_is_valid(event_code, ticket_count):
# Return True only when both booking rules are satisfied.
pass
result = booking_is_valid("MUSIC", 2)
Maintainability in context
The following code works, but its names do not explain the festival calculation:
def f(a, b):
x = a * b
return x
Imagine that a is the number of tickets and b is the price of one ticket. A future programmer should not have to infer those meanings.
Describe two specific ways to improve the maintainability of the festival calculation.
Refer directly to identifiers, comments, indentation or subprogram structure in the supplied code. Do not recommend a feature that is already adequate unless you explain a genuine change.
Students type their answer here.
Refine a logic error
The next function should multiply quantity by price, but it currently adds them. Correct the logic error without changing the function's parameters or return structure.
def calculate_booking_total(ticket_count, ticket_price):
booking_total = ticket_count + ticket_price
return booking_total
total = calculate_booking_total(3, 5)
Explain how iterative testing and final testing should both be used while developing the festival system.
Apply iterative testing to a module and final testing to the combined system. Explain the purpose of each stage.
Students type their answer here.
Create a four-row test plan for ticket_count, which accepts integers from 1 to 6 inclusive. Include normal, valid boundary, invalid and erroneous data with expected results.
Use a table with value, type and expected result. Give specific values.
Students type their answer here.
Evaluate the robustness of a festival system that checks ticket quantities but has no sign-in check, accepts any event code and has only been tested with the value 3.
Develop three separate chains. For each: identify a weakness, explain a suitable improvement and link it to a consequence for this festival system. Finish with a brief judgement.
Students type their answer here.
Final review
You should now be able to move from a requirement to a safeguard, from a safeguard to code, and from code to a focused test plan. Before finishing, retrieve one precise definition for each of these terms: defensive design, authentication, validation, maintainability, iterative testing, final testing, syntax error, logic error and boundary data.
In longer OCR answers, attach every point to the scenario. A named technique is a starting point; the marks usually come from explaining how it works and what difference it makes.