The Bug Hunt (Guess First!)

A free sample lesson from Thinking Like a Coder

The idea

A magnifying glass moving over the steps one at a time - but only after the detective has said out loud who they think did it.

What it actually is

Debugging is finding out why something doesn't work, and it is a loop you go round, not a lucky guess. Read what went wrong. PREDICT what you think is causing it. Check whether you were right. Fix one thing. Then round again. The predict step is the one nearly everybody skips, and skipping it is the difference between hunting a bug and just poking your program until the red goes away. Saying your guess out loud first means you learn something whether you're right or wrong.

A worked example

1. READ:     'the score shows 0'
2. PREDICT:  'I bet I'm showing the score before adding it'
3. CHECK:    look - yes, the show line is above the add line
4. FIX:      move one line, then go round again

Notice step 2 happens before you touch anything. You commit to a guess, THEN look. If you're wrong, you've learned something real about your program. If you never guess, you learn nothing either way.

Mistakes children actually make

Mistake 1: changing lots of things at once. Then you can't tell which change helped, and you've probably added a new bug. One change, then check. Mistake 2: not reading the error message. It is genuinely trying to help you and it usually names the line.

Then they try it

In the app this lesson continues with the animated explanation, spoken aloud, and then the practice: Order the four cards into the bug-hunting loop. One of them is the step almost everyone skips - make sure it doesn't end up last. The editor runs your child’s real code and checks the result, with their coding buddy reacting to what they wrote.

Try it free