OCR J277 GCSE Computer Science · 2.3 Producing Robust Programs
Stretch tasks Producing Robust Programs
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
Sort It
Sort each statement into the right box, like the tick-box tables in the exam.
- 11 cards to sort into 3 boxes
- Drag a card, tap a box or press its number
- Combo points for cards sorted in a row
11 cards, about 4 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Producing Robust Programs
Producing Robust Programs: the questions
Quiz Challenge, round 1: Quiz Blitz
Which validation check makes sure an age is between 0 and 120?
- Length check
- Format check
- Range check
- Presence check
Which validation check makes sure a surname is not left blank?
- Range check
- Type check
- Look up check
- Presence check
Validation checks that data has been entered correctly.
- True
- False
A program crashes when it divides by zero. Which type of error is this?
- Syntax error
- Logic error
- Validation error
- Runtime error
A missing colon stops a Python program from running at all. Which type of error is this?
- Boundary error
- Syntax error
- Logic error
- Runtime error
A program uses + where it should use *, so the total is wrong. Which type of error is this?
- Logic error
- Syntax error
- Runtime error
- Format error
Ages 11 to 18 are allowed. Which TWO values are boundary test data?
Tick 2.
- 14
- 25
- "fourteen"
- 11
- 18
What name is given to testing carried out during development, as each part is written?
What does authentication do?
- Checks data is sensible
- Finds syntax errors
- Compresses passwords
- Confirms a user is who they claim to be
Which TWO improve maintainability?
Tick 2.
- Comments explaining why
- Single-letter variable names
- Removing all indentation
- Copying the same code into many places
- Meaningful variable names
Why should passwords be stored hashed?
- It stops users forgetting them
- A stolen database does not reveal them
- Hashing makes them shorter to type
- Hashed passwords never expire
A test plan should state the expected result of every test.
- True
- False
Quiz Challenge, round 2: Quick Fire
Explain the difference between validation and verification. [2 marks]
A program accepts ages from eleven to eighteen. Give one normal, one boundary and one erroneous test value. [3 marks]
Give two ways to make a program more maintainable. [2 marks]
Explain why boundary data is the most valuable test data. [2 marks]
Quiz Challenge, round 3: Big Think
A sign-up form asks for a username and an age from 13 to 100. Describe how validation could be used to make the program robust. [6 marks]
Compare iterative testing with final testing, and explain why a program needs both. [4 marks]
This or That: tick the right answer
Which of these is a format check?
- A surname must not be blank
- An email must contain an at sign
Asking for a new password twice is...
- Validation
- Verification
Which error is harder to spot?
- A syntax error
- A logic error
A check is written as > 11 instead of >= 11. Which test value catches it?
- 14
- 11
Testing an age box with "fourteen" uses which type of data?
- Boundary
- Erroneous
What does two factor authentication add?
- A second check, such as a code sent to a phone
- A second password box on the same page
Opening a file that does not exist crashes a program. What kind of error is that?
- A syntax error
- A runtime error
Final testing checks the program against...
- The programmer's memory
- The original requirements
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Range check | 1 Runs, but gives the wrong result |
| B Presence check | 2 Values at the very edge of the range |
| C Length check | 3 Breaks the language's rules, so it won't run |
| D Syntax error | 4 Something has been entered |
| E Logic error | 5 Between a lower and an upper limit |
| F Boundary data | 6 The right number of characters |
Sort It: tick one box in each row
Syntax error, logic error or runtime error?
| Statement | Syntax error | Logic error | Runtime error |
|---|---|---|---|
| Dividing by zero | |||
| Reading item 10 of a list with 5 items | |||
| Using > where >= was needed | |||
| Printing the average before it is calculated | |||
| Using + where * was intended | |||
| A bracket that is never closed | |||
| A missing colon after an if statement | |||
| A loop that adds 1 to the wrong variable | |||
| Converting the text abc to a whole number | |||
| Opening a file that does not exist | |||
| A misspelled keyword, such as whlie |
Answers
Round 1: Quiz Blitz
- Range check A range check tests that a value falls between an upper and a lower limit.
- Presence check A presence check makes sure something has been entered.
- False Validation checks data is sensible. Verification checks it was entered correctly.
- Runtime error The code is valid, but it crashes while running.
- Syntax error It breaks the rules of the language, so the program cannot run.
- Logic error It runs perfectly and quietly gives the wrong answer: a logic error.
- 11; 18 Boundary data sits at the very edge of the range. 14 is normal, 25 is invalid, and text is erroneous.
- iterative testing Iterative testing finds problems early, when they are cheap to fix.
- Confirms a user is who they claim to be Passwords, two factor authentication and biometrics are all ways to authenticate.
- Meaningful variable names; Comments explaining why Indentation, subroutines and constants help too.
- A stolen database does not reveal them A hash cannot simply be read back as the password.
- True Without an expected result, there is nothing to compare the actual result with.
Round 2: Quick Fire
- Validation checks that data is sensible and in the right format
- Verification checks that data was entered correctly, for example by typing it twice
Model answerValidation checks that data is sensible and in the right format before it is used. Verification checks that it was entered correctly, for example by asking for a password twice.
- Normal: a typical age inside the range
- Boundary: a value at the edge of the range
- Erroneous: data of the wrong type
Model answerNormal: 14. Boundary: 11. Erroneous: "fourteen", which is text rather than a number.
- Meaningful identifiers
- Comments
- Indentation
- Subroutines
- Constants
- White space
Model answerUse meaningful variable names, such as totalPrice instead of tp, and add comments that explain why the code does something.
- It tests the very edge of the allowed range
- That is where off by one mistakes, such as > instead of >=, are caught
Model answerBoundary data tests the very edge of the allowed range, which is exactly where off by one mistakes hide: a check written as > 11 instead of >= 11 is only caught by testing 11.
Round 3: Big Think
- A presence check on the username
- A length check on the username
- A type check that the age is a whole number
- A range check on the age
- A loop asks again until the input is valid, instead of crashing
- An error message tells the user what to enter
- This is defensive design: it anticipates misuse
Model answerA presence check makes sure the username is not left blank, and a length check could make sure it is at least 3 characters long. A type check makes sure the age is a whole number, so typing letters cannot crash the program, and a range check makes sure it is between 13 and 100. If any check fails, the program shows an error message that tells the user what to enter, and a while loop asks again until the input is valid. This is defensive design: it anticipates misuse instead of crashing.
- Iterative testing happens during development, as each part is written
- So problems are found early, when they are cheap to fix
- Final testing happens when the program is complete
- It checks the program against the original requirements
- Parts that work alone can still fail when combined
Model answerIterative testing happens during development: each part is tested as it is written and corrected before moving on, so problems are found early, when they are cheap to fix. Final testing happens when the program is complete: the whole program is tested against the original requirements. Each part can work on its own while the parts fail when combined, so testing the whole program together is still needed.
This or That
- An email must contain an at sign A format check tests for a pattern. Not blank is a presence check.
- Verification Typing it twice checks it was entered correctly: verification.
- A logic error The translator finds syntax errors for you. A logic error runs quietly with the wrong answer.
- 11 Only a test on the boundary itself shows the difference.
- Erroneous Erroneous data is the wrong type entirely, and should be rejected.
- A second check, such as a code sent to a phone A stolen password alone is no longer enough to get in.
- A runtime error The code is valid, so it starts, then crashes while running.
- The original requirements It confirms the program does everything it was supposed to.
Memory Match
- A 5 Range check: Between a lower and an upper limit
- B 4 Presence check: Something has been entered
- C 6 Length check: The right number of characters
- D 3 Syntax error: Breaks the language's rules, so it won't run
- E 1 Logic error: Runs, but gives the wrong result
- F 2 Boundary data: Values at the very edge of the range
Sort It
- Runtime error Dividing by zero The program crashes while running.
- Runtime error Reading item 10 of a list with 5 items The index is out of range, so the program crashes.
- Logic error Using > where >= was needed The program runs, but gets the boundary wrong.
- Logic error Printing the average before it is calculated The steps are in the wrong order, so the output is wrong.
- Logic error Using + where * was intended It runs, but the answer is wrong.
- Syntax error A bracket that is never closed Unclosed brackets break the language's rules.
- Syntax error A missing colon after an if statement It breaks the rules of Python, so it will not run.
- Logic error A loop that adds 1 to the wrong variable No crash, just a wrong result.
- Runtime error Converting the text abc to a whole number int() fails on letters while the program runs.
- Runtime error Opening a file that does not exist The code is fine, but it fails at run time.
- Syntax error A misspelled keyword, such as whlie The translator cannot understand the misspelled keyword.