AQA 8525 GCSE Computer Science · 3.2 Programming

Stretch tasks Robust and Secure Programming

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

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

Task 3

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

Task 4

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: Robust and Secure Programming

Robust and Secure Programming: the questions

Quiz Challenge, round 1: Quiz Blitz

  1. What does validation check?

    • That the user is who they claim to be
    • That the code has no syntax errors
    • That data is reasonable
    • That data is correct
  2. Which check makes sure a county is chosen from a known list?

    • Presence check
    • Look up check
    • Range check
    • Length check
  3. A date of birth that passes every validation check must be correct.

    • True
    • False
  4. Which question does authentication answer?

    • Who are you?
    • Is that a sensible value?
    • Is the code correct?
    • Which data type is it?
  5. Which TWO strengthen password authentication?

    Tick 2.

    • Allowing very short passwords
    • Showing the password on screen
    • Emailing passwords in plain text
    • Locking the account after several failed attempts
    • Two factor authentication
  6. A program reads past the end of an array and stops. What kind of error is this?

    • Format error
    • Runtime error
    • Syntax error
    • Logic error
  7. Using < where ≤ was meant gives...

    • A runtime error
    • No error at all
    • A logic error
    • A syntax error
  8. Ages 0 to 120 are allowed. Which TWO are boundary values just outside the limits?

    Tick 2.

    • -1
    • 121
    • 0
    • 35
    • "cat"
  9. What is test data that should be rejected, such as "cat" for an age, called?

  10. Which comment is most useful?

    • # variable
    • # skip the header row of the file
    • # add one to count
    • # this is a loop
  11. Iterative testing happens during development.

    • True
    • False
  12. What does fail helpfully mean in defensive design?

    • Restart the computer
    • Show a message saying what went wrong and what to do
    • Crash quickly
    • Hide every error

Quiz Challenge, round 2: Quick Fire

  1. Explain why validation cannot guarantee that data is correct. [2 marks]

  2. Explain the difference between authentication and validation. [2 marks]

  3. An age must be from zero to one hundred and twenty. Give one item each of normal, boundary and erroneous test data. [3 marks]

  4. Give two ways to make code more maintainable. [2 marks]

Quiz Challenge, round 3: Big Think

  1. Explain the three kinds of error a program can have, with an example of each. [6 marks]

  2. A login system is being tested. Explain how to choose test data, and why both iterative and final testing are needed. [6 marks]

This or That: tick the right answer

  1. Typing an email address twice to check it matches is...

    • Validation
    • Verification
  2. An email must contain an at sign. Which check is that?

    • Length check
    • Format check
  3. A password must be at least 8 characters. Which check is that?

    • Length check
    • Range check
  4. Which error does the translator report, often with a line number?

    • A logic error
    • A syntax error
  5. Where should a boundary be tested?

    • On one side only
    • On both sides of the limit
  6. Which identifier is better?

    • totalPrice
    • x2
  7. Two factor authentication asks for something you know and...

    • Something you forgot
    • Something you have
  8. When should a program check permission?

    • Before doing anything sensitive
    • After the action is done

Memory Match: match each term to its meaning

TermMeaning
A Range check1 Stops while the program runs
B Presence check2 One of a known set of values
C Look up check3 Something was entered
D Syntax error4 Data that should be rejected
E Runtime error5 Breaks the language's rules
F Erroneous data6 Between two limits

Sort It: tick one box in each row

An age must be from 0 to 120. Normal, boundary or erroneous test data?

StatementNormalBoundaryErroneous
An empty entry
-1
120
0
12
121
3.5
35
64
"twenty"
"cat"
Answers

Round 1: Quiz Blitz

  1. That data is reasonable Validation checks plausibility. It cannot detect a lie.
  2. Look up check A look up check accepts only values in a known set.
  3. False 01/01/1990 passes every check, and is wrong for someone born in 1991.
  4. Who are you? Validation answers whether a value is sensible.
  5. Locking the account after several failed attempts; Two factor authentication Minimum lengths and asking for characters from a memorable word help too.
  6. Runtime error It starts, then stops while executing.
  7. A logic error It runs, but gives the wrong answer at the boundary, and nothing reports it.
  8. -1; 121 0 and 120 are on the boundary. -1 and 121 are just outside it.
  9. erroneous Erroneous data checks that the validation works.
  10. # skip the header row of the file A useful comment explains why, not what.
  11. True Module by module, while the code is still fresh and small.
  12. Show a message saying what went wrong and what to do A clear message lets the user recover. A crash does not.

Round 2: Quick Fire

    • Validation only checks that data is reasonable
    • A wrong value, such as a mistyped date of birth, can still pass every check
    Model answer

    Validation only checks that data is reasonable. A wrong value, such as a date of birth that is a year out, can still pass every check.

    • Authentication checks a user is who they claim to be
    • Validation checks that input data is reasonable
    Model answer

    Authentication checks that a user is who they claim to be, for example with a password. Validation checks that the data entered is reasonable.

    • Normal: a typical age
    • Boundary: an age on or just outside a limit
    • Erroneous: data that should be rejected
    Model answer

    Normal: 35. Boundary: 120. Erroneous: "cat".

    • Meaningful identifiers, such as totalPrice instead of tp
    • Comments that explain why
    • Indentation that shows the structure
    • Subroutines, so each task is in one place
    Model answer

    Use meaningful identifiers, such as totalPrice instead of tp, and add comments that explain why the code does something, not what it does.

Round 3: Big Think

    • A syntax error breaks the rules of the language, so it will not run
    • Syntax example: a missing bracket or misspelled keyword
    • A logic error runs but gives the wrong result
    • Logic example: + where - was meant, or < instead of ≤
    • A runtime error stops the program while it runs
    • Runtime example: dividing by zero, or reading past the end of an array
    Model answer

    A syntax error breaks the rules of the language, such as a missing bracket or a misspelled keyword, so the program will not run at all. A logic error means the program runs but gives the wrong result, such as using + where - was meant. A runtime error happens while the program is running and stops it, such as dividing by zero or reading past the end of an array.

    • Normal data the program should accept
    • Boundary data on both sides of each limit
    • Erroneous data the program should reject
    • Boundaries are where off by one bugs show up
    • Iterative testing finds faults early, during development
    • Final testing checks the whole program against the requirements
    Model answer

    Test data should include normal data, such as a valid username, which should be accepted; boundary data on both sides of each limit, such as a password of exactly the minimum length and one character shorter; and erroneous data, such as a blank entry, which should be rejected. Boundaries matter most, because off by one bugs show up there and nowhere else. Iterative testing during development finds faults early, when they are cheap to fix, and final testing checks the whole program against the original requirements.

This or That

  1. Verification Verification checks data was entered accurately.
  2. Format check It checks the data matches a pattern.
  3. Length check It counts characters, not the size of a number.
  4. A syntax error Nothing reports a logic error: the program just gives the wrong answer.
  5. On both sides of the limit Test 120 and 121, and 0 and -1.
  6. totalPrice Meaningful names make code maintainable.
  7. Something you have Such as a code sent to your phone.
  8. Before doing anything sensitive Authenticate before acting, not after.

Memory Match

  • A 6 Range check: Between two limits
  • B 3 Presence check: Something was entered
  • C 2 Look up check: One of a known set of values
  • D 5 Syntax error: Breaks the language's rules
  • E 1 Runtime error: Stops while the program runs
  • F 4 Erroneous data: Data that should be rejected

Sort It

  1. Erroneous An empty entry Nothing was entered, so it must be rejected.
  2. Boundary -1 Just outside the lower limit: test both sides of a boundary.
  3. Boundary 120 On the upper limit.
  4. Boundary 0 On the lower limit.
  5. Normal 12 A normal, valid age.
  6. Boundary 121 Just outside the upper limit.
  7. Erroneous 3.5 An age must be a whole number.
  8. Normal 35 A typical age that should be accepted.
  9. Normal 64 Comfortably inside the range.
  10. Erroneous "twenty" A word, not a number.
  11. Erroneous "cat" Not a number at all, so it must be rejected.