Skip to main content
Back to module
Teaching Computer Science · CS Pedagogy

PRIMM and pair programming

Reading50mLesson 2 of 3 in this module

Plan a PRIMM lesson and run structured pair programming with clear roles.

Why it matters

Many beginner programming lessons jump straight to "write a program that...". For novices this is like asking someone to write an essay in a language they have only heard spoken. They stare at a blank editor, copy something from the internet, or give up. Two well-researched approaches give students a gentler, more structured path: PRIMM for lesson structure and pair programming for collaboration.

PRIMM: read before you write

PRIMM was developed by Sue Sentance and colleagues in England. It moves students from reading code to writing it in five stages:

StageStudents...Teacher's role
Predictread a short program and predict its output, without running itchoose code that uses the new concept in a familiar context
Runrun it and compare with their predictiondiscuss surprises; misconceptions surface here
Investigatetrace, annotate, answer questions, change one thing and observeask targeted questions about each line
Modifychange the program to do something slightly differentscaffold from small to larger changes
Makewrite a new program that uses the conceptprovide a clear task and an extension

The key idea is that reading and understanding code comes before writing it. Students get a working example to reason about, so their first experience is success, not a blank screen. The approach also gives you natural checkpoints: if many predictions are wrong, you stay longer on Investigate.

Worked example: a PRIMM lesson on for loops

Predict:

total = 0
for n in range(1, 4):
    total = total + n
print(total)

"What will this print? Write your answer before running it." Common predictions: 6 (correct), 10 (thinking range includes 4), or 3 (thinking the loop runs once).

Run: students run it and compare. Discuss why range(1, 4) gives 1, 2, 3.

Investigate:

  1. Add a print(n, total) inside the loop. What do you see?
  2. What would range(1, 6) print? Predict, then check.
  3. What happens if total = 0 is moved inside the loop? Why?

Modify: make it add only even numbers from 2 to 10.

Make: write a program that multiplies the numbers 1 to 5 (5 factorial), then an extension: ask the user for n.

Pair programming: two people, one problem

In pair programming, two students work on one computer:

  • The driver types and focuses on the current line.
  • The navigator reads, checks, thinks ahead and suggests.
  • They swap roles regularly, often every 5-10 minutes, with a timer.

Studies in university and school settings have linked pair programming with better completion rates, more confidence and better retention, including for students under-represented in computing. It also reduces the number of "I'm stuck" hands, because pairs solve many problems themselves.

Making pairing work

Pairing fails when one student does everything. Structure helps:

  • Role cards on the desk describing what each role does and says.
  • A visible timer and a clear signal to swap.
  • Talk norms: the navigator suggests, does not grab the keyboard; the driver explains what they are typing.
  • Thoughtful pairing: pair students of similar confidence where possible, and change pairs between units.
  • Individual accountability: short individual exit questions so you can still see what each student understands.

PRIMM and pairing combine well: pairs predict and investigate together, then each student does a short individual Make task.

Common mistakes

  • Skipping Predict. Running code first removes the moment where misconceptions show.
  • Investigate questions that only ask "what does it print?" Ask "why?" and "what if?" too.
  • Unstructured pairs. Without roles and swaps, the more confident student drives the whole time.
  • No individual check. Pairs can hide a student who has not understood.

Quick recap

  • PRIMM = Predict, Run, Investigate, Modify, Make: read and reason about code before writing it.
  • Predictions surface misconceptions; Investigate questions deepen understanding.
  • Pair programming uses driver and navigator roles with regular swaps.
  • Structure pairing with role cards, timers and individual exit checks.

Try it

Open the Do tab and plan a 50-minute PRIMM lesson that uses pair programming.

Also in this lesson: