Study Guide Instructor view

Tackling a Programming Scenario

Teaching notes for Lesson 5.16, with controls for presenting it.

Keep this page on your own screen. Share only the lesson window. The lesson window holds no teaching notes, so sharing it cannot show them.

Presenting

  1. Open the lesson in its own window and share that window, not this one.
  2. Use Next and Previous here, or the lesson’s own, to move through the lesson. Next reveals one thing at a time: the next idea, or the answer to the question on screen, then the next step. Previous takes the last reveal back. The line below says what is on screen and what Next will show.
  3. Reveal hints and answers when the class is ready, and reset a demonstration before using it again.

The controls need JavaScript and a browser that supports BroadcastChannel. Without them, open the lesson in presentation mode and use its own controls.

The two windows talk to each other only inside this browser, on this device. Nothing is sent to a server, and no account is needed. A second device (a phone or another tablet) cannot follow the lesson window yet.

Lesson plan

Level
Intermediate
Time
About 120 minutes; the steps below add up to 122

Pupils meet a page of requirements and are led through the process of turning it into a tested program: annotate, decompose, choose data structures, write in stages, test with chosen data and check against the words. The method is then used independently on a second scenario with a checklist of what a strong answer shows.

Objectives

  • Read a scenario and pick out its inputs, processes, outputs, storage and rules
  • Break a scenario into smaller tasks and put them in a sensible order
  • Choose arrays and variables for the data a scenario needs
  • Write a solution in stages, testing each stage before adding the next
  • Choose test data for the whole solution and check the result against the requirements
  • Write a complete solution to a new scenario and check it against a list of what a strong answer shows

Before the lesson

  • Paper and coloured pens or highlighters for annotating the requirements.
  • A printed copy of each scenario so that pupils can underline on it.
  • Mini whiteboards for the test plan. Allow the full time for step 8, which is the independent writing.

Steps

  1. Introduction Opening

    On screen: the lesson’s title, module and number; Next adds its objectives and key terms, as the lesson page lists them; Next again begins the first step.

    Objectives on screen

    • Read a scenario and pick out its inputs, processes, outputs, storage and rules
    • Break a scenario into smaller tasks and put them in a sensible order
    • Choose arrays and variables for the data a scenario needs
    • Write a solution in stages, testing each stage before adding the next
    • Choose test data for the whole solution and check the result against the requirements
    • Write a complete solution to a new scenario and check it against a list of what a strong answer shows

    Purpose: Pupils meet a page of requirements and are led through the process of turning it into a tested program: annotate, decompose, choose data structures, write in stages, test with chosen data and check against the words. The method is then used independently on a second scenario with a checklist of what a strong answer shows.

  2. 1. A page of words Think 12 min

    Purpose: Pupils read a long scenario and annotate it before any code exists, so that annotation is a habit and not something told to them.

    Ask

    • What goes in, what is stored, what is worked out and what comes out?
    • Which requirement is a rule?

    Responses to expect

    • Names and distances in; arrays for storage; average, furthest and count; three outputs
    • Requirement 2, the range 0 to 10

    Misconceptions to challenge

    • A learner may believe: “Start by writing the first line of code.” Respond: Spend the first minutes reading and marking. What would you miss if you did not?

    On the board or with the pen

    • Redraw the five kinds (input, storage, process, output, rule) as a five-row table and fill it with the class’s answers.

    Discussion pause: Three minutes of silent annotation on paper.

    In the lesson window

    • Think it through: Before writing any code, read the six requirements again. List what the program takes in, what it has to work out, what it has to remember, what it outputs and what rules it must follow.
  3. 2. Breaking it into smaller jobs Discover 10 min

    Purpose: Pupils decide the order of the jobs before decomposition is named.

    Ask

    • What are the four or five jobs, in order?
    • Which results can only be worked out at the end?

    Responses to expect

    • Input and validate, calculate during the loop, average at the end, output
    • The average, the winner and the count

    Misconceptions to challenge

    • A learner may believe: “The output lines should come first.” Respond: The outputs depend on everything else. What can be output before any data is in?

    Checking understanding: The sort-requirements table.

    English as an additional language

    • Check input, process, output and storage with one example of each.

    In the lesson window

    • Think it through: Break the problem into four or five smaller jobs, in the order the program would do them. Each should be small enough that you could write it on its own.
  4. 3. Where the data lives Predict 10 min

    Purpose: Pupils choose arrays for themselves and see why parallel arrays share an index.

    Ask

    • Why not ten separate variables?
    • How are a name and a distance matched?

    Responses to expect

    • A hundred for fifty pupils; one loop does it for an array
    • By the same position

    Misconceptions to challenge

    • A learner may believe: “Two arrays are two separate lists with no link.” Respond: The link is the position. Names[3] and Distances[3] describe the same pupil.

    Checking understanding: The same-index question.

    In the lesson window

    • Think it through: The program must still know all five names and distances when it has finished the input, because the winner’s name is needed at the end. How would you store them? Why would five separate variables for the names and five for the distances be a poor choice?
    • Check your understanding: Why must Names and Distances use the same position for the same pupil?
  5. 4. Writing the first part, and testing it Explain 15 min

    Purpose: Writing and testing the first stage alone, with the misconception about writing everything at once named.

    Ask

    • What do you write first?
    • Why test before you add more?

    Responses to expect

    • Input and validation
    • A fault must be in the newest part

    Misconceptions to challenge

    • A learner may believe: “It is quicker to write everything and test once.” Respond: A fault could be anywhere. Staged testing makes faults quick to find.

    Checking understanding: The order-of-work question and the stage-one trace.

    In the lesson window

    • Think it through: Which part of the program would you write first, and would you write the whole program and then test it, or test as you go? Say why.
    • Check your understanding: Which is the best order for writing and testing the program?
  6. 5. Adding the calculations Predict 15 min

    Purpose: Adding the calculations and tracing them, with a position stored so that the name can be found.

    Ask

    • Which variables are needed, and what should each start as?
    • Why store a position and not a distance?

    Responses to expect

    • Total 0, Winner 1, Qualified 0, all before the loop
    • The name and the distance can both be found from it

    Misconceptions to challenge

    • A learner may believe: “Total ← 0 can go inside the loop to keep things tidy.” Respond: It would be reset on every pass; use the totalling rule from Lesson 6.

    On the board or with the pen

    • Trace the five pupils on the board, with a pupil at the board and the class checking.

    Checking understanding: The stage-two trace and the why-winner-index question.

    Depending on the answers

    • If pupils struggle with the Winner column: trace it with the five distances written on cards and ask who is winning after each card

    In the lesson window

    • Think it through: Which variables does stage two need, what should each start as, and where should those starting values be set?
    • Check your understanding: Why does the program keep the position of the furthest jump in Winner, and not the distance itself?
  7. 6. Testing with chosen data Apply 12 min

    Purpose: Choosing test data for the range rule, then checking each requirement against the program.

    Ask

    • Which four values are boundary data?
    • Which value would find a wrong limit?

    Responses to expect

    • -0.1, 0, 10 and 10.1 at one decimal place
    • 0 or 10

    Misconceptions to challenge

    • A learner may believe: “The boundary values are only 0 and 10.” Respond: The nearest refused values are boundary data as well.

    Checking understanding: The test plan table and the limit-test question.

    Stretch

    • Choose test data for the count of distances of 4.5 or more, including the value exactly 4.5.

    In the lesson window

    • Think it through: Choose test data for the distance rule, 0 to 10 metres, including normal, extreme, boundary and abnormal data, and state whether each should be accepted. Which four values are the boundary data?
    • Check your understanding: A programmer has typed UNTIL Distances[Index] > 0 AND Distances[Index] < 10 by mistake. Which test value from the plan shows this?
  8. 7. The method, in six moves Explain 10 min

    Purpose: Pupils reconstruct the method in their own words, then see it as six moves and apply it to someone else’s approach.

    Ask

    • What were the moves, in order?
    • Which move did Sam skip?

    Responses to expect

    • Annotate, decompose, structures, stage, test, check
    • Reading and annotating

    Misconceptions to challenge

    • A learner may believe: “Planning is a waste of time in an exam.” Respond: The first minutes decide what the program must contain.

    Checking understanding: The sam-starts-typing question.

    In the lesson window

    • Think it through: Look back over what you have done in this lesson. In your own words, list the moves that took you from the page of words to a tested program, in order.
    • Apply it: Sam starts writing code as soon as the question appears, and later finds that the program does not refuse a distance of 12. Which move did Sam probably skip or rush?
  9. 8. Now write one yourself Apply 30 min

    Purpose: Independent writing of a complete solution to a new scenario, then self-checking against the checklist.

    Ask

    • Which array do you still need to declare?
    • What does the total add for each snack?

    Responses to expect

    • Sold
    • The number sold times the price

    Misconceptions to challenge

    • A learner may believe: “The total should add only the number sold.” Respond: Money needs the price. Work one snack by hand.
    • A learner may believe: “A passing answer has output in the loop.” Respond: Outputs for the whole day belong after the loop.

    Checking understanding: Pupils mark their own answer against the checklist, then swap with a partner.

    Depending on the answers

    • If pupils cannot start: ask them to annotate the requirements into the five kinds first and show you
    • If pupils finish early: ask them to choose the test data and write the expected output

    Support

    • Give the first stage (the input loop with validation) and ask for the rest.

    English as an additional language

    • Check the words fewer than, sold and best-selling; pupils may write the plan as a list first.

    Discussion pause: Allow at least fifteen minutes in silence.

    In the lesson window

    • Think it through: Follow the six moves. Annotate the requirements, list the jobs, choose the arrays and variables, and then write the algorithm in pseudocode or Python. Test it with 40, 8, 25, 60 and 9 sold, and say what it should output.
    • Apply it: A learner’s answer has Total ← Sold[Index] * Price[Index] inside the loop, in place of the line that adds. With the data 40, 8, 25, 60 and 9, what is wrong, and what does it output for the total?
  10. 9. Show what you know Consolidate 8 min

    Purpose: Explanation of the opening minutes of a long question, and a last choice of structures.

    Ask

    • What do you do in the first five minutes?
    • Which structures suit twenty ages and a count?

    Responses to expect

    • Annotate, list the jobs, choose the structures and starting values
    • An array of 20 and a counter starting at 0

    Checking understanding: The new-scenario-rule question; read two answers to the first-five-minutes question aloud.

    In the lesson window

    • Think it through: In a 30-minute scenario question, you have just read the whole description. What do you do in the first five minutes before writing any code, and why does it help?
    • Apply it: A new scenario says: “the program stores the ages of 20 members of a swimming club and outputs the number who are under 12”. Which pair of choices is the best start?
  11. Lesson recap Closing

    On screen: the lesson’s objectives again; Next adds the closing question, which asks the class to explain each one in their own words without looking back. It says nothing about what anyone has learnt: use the answers to decide what to revisit.

    Points to listen for

    • Annotate the scenario first: inputs, storage, processes, outputs and rules.
    • Decomposition gives the order: input and validate, calculate, output.
    • Write and test one stage at a time; choose test data, including the limits, in advance.
    • Finish by checking every requirement against the program.

Consolidation

  • Annotate the scenario first: inputs, storage, processes, outputs and rules.
  • Decomposition gives the order: input and validate, calculate, output.
  • Write and test one stage at a time; choose test data, including the limits, in advance.
  • Finish by checking every requirement against the program.