Skip to content

Plan Before Code

Ten minutes of planning saves an hour of confused typing. Use lists, sketches and trace tables before you open an editor.

Class 9 to 10beginner15 min3 lessons1 interactive lab
By the end you will be able to
  • Pick the right planning tool for a task
  • Review a plan with a partner before coding
  • Revise plans when tests fail instead of patching randomly

Finish first

Lesson 1 of 3

Tools you already have

You now know three tools: break a task into steps, trace tiny programs on paper, and backtrack when choices fail. Planning means picking the right tool first.

A game level might need a sketch of states. A maths helper might need a trace table for formulas. A search problem might need a maze-style map.

Open the plan order lab. Watch a plan fail when steps are out of order, then see the fixed version succeed before you type any code.

Interactive lab

Plan order

Watch a homework plan run in the wrong order and fail, then reorder steps so inputs come before outputs.

Plan order

Put steps in the right order before you start

Average three test scores

You wrote a plan before doing the job. Step through it like a robot would.

  1. 1.Print the average
  2. 2.Read score one, score two and score three
  3. 3.Add the three scores
  4. 4.Divide the total by three
1 / 7

Wrong plan

Printing the average first sounds fine in English, but the computer has no numbers yet. Order matters.

Continue

Lesson 2 of 3

Review with someone else

Swap plans with a classmate. Ask: is any step vague? Does order make sense? Could we trace the first ten lines together?

Teachers call this peer review. It is not cheating. It is how teams catch mistakes before they become bugs.

Keep plans short. One page beats ten. If the plan grows huge, your subtasks are probably still too big.

Continue

Lesson 3 of 3

When tests fail

Failing tests are clues, not insults. Read the expected against actual output. Trace the table to the line where values diverge. Update the plan, then update the code.

Random edits without a plan often create new bugs. Fix the idea first, then the typing.

You finished the problem solving pillar. Carry these habits into every programming class ahead.

Continue

Practice

Work these out yourself

No answer key here on purpose: these are the questions worth thinking through before you move on. Open one and work it out.

0/3 attempted

Assessment

Check your understanding

Answer each question, then read the explanation. That is where the learning is.

0/4
  1. Question 1: Planning before code mainly saves what?
    Question 1 / 4

    Planning before code mainly saves what?

    Select an option first
  2. Question 2: Peer review of a plan helps because what?
    Question 2 / 4

    Peer review of a plan helps because what?

    Select an option first
  3. Question 3: When a test fails, a good first move is what?
    Question 3 / 4

    When a test fails, a good first move is what?

    Select an option first
  4. Question 4: A plan that fills many pages probably means what?
    Question 4 / 4

    A plan that fills many pages probably means what?

    Select an option first
4 of 4 questions left.

Finished this topic?

0 of 3 lessons marked done. Marking the topic complete ticks the rest.