← Back to course
Code Crew G3 / Week 06 / Monday
1/6
Week 06 Β· Debugging

Monday

// Finding the broken step

Monday: Meet the Idea

Rocket is ready for a test flight. His steps say press launch, put on helmet, then buckle the pack.

Raven holds up a hand. "Wait! What do you notice about the first step?" Rocket reads it again. "Oh no. I launch before my helmet is on!"

Nova blinks. "That is a bug. Bugs are normal. Let's debug together." Rocket fixes the order with a smile. Now let's hunt for a bug in some shoe steps.

ROCKET wrote steps for a test flight. 1) press launch, 2) put on helmet, 3) buckle rocket pack. The helmet and pack must come BEFORE launch. That's a BUG. Rocket needs to gear up first, THEN launch. Let's practice being bug detectives.

Big Idea
Code often needs fixing.
DEBUGGING is normal. Pros do it too.
Read carefully. Try one step at a time.

How Bug Detectives Work

Bugs are normal. Every programmer meets them.

A bug detective follows the same plan each time. Test it, find where it goes wrong, fix it, then test again.

THE DEBUGGING PLAN
  • ?Run the program and watch
  • ?Find the first step that goes wrong
  • ?Change that step
  • ?Run it again to check
WHY THIS EXERCISEFollowing the same plan every time makes any bug easier to find.
THINK LIKE A BUG DETECTIVE
  • Read the question.
  • Tap your answer.
Rocket says: my code has a bug, so I give up. What would Nova say?
Steps: put on helmet, press launch, buckle the pack. Which step is in the wrong place?
After you fix a bug, what should you do next?
What is the best way to find a bug?
StatementTrue or false?
Even expert programmers make bugs.?
A bug means the whole program must be thrown away.?
Testing again after a fix is a good habit.?
Reading one step at a time helps you find bugs.?
WHY THIS EXERCISEBugs are part of coding. Fixing them is how programs get better.
Steps: 1. Pour the water. 2. Get a cup. 3. Drink. Which step should come first?
Steps: 1. Brush your teeth. 2. Put toothpaste on the brush. Which step should come first?
Steps: 1. Open the box. 2. Take out the toy. 3. Close the box. Is there a bug? Type yes or no.
A program should say 1, 2, 3. It says 1, 3. Which number is missing?
WHY THIS EXERCISEComparing what you wanted with what happened points right at the bug.
Try it
Ask a grown-up to give you steps with one hidden bug.
Act out the steps slowly.
Stop at the first step that goes wrong.

Spot the Bug

Read these steps for tying a shoe. Which step is in the WRONG ORDER?

(RE-NUMBER THE STEPS)
  • ?Make two loops
  • ?Pull the laces tight
  • ?Cross the laces
  • ?Tie the loops into a knot
WHY THIS EXERCISEDebugging is finding the step that's out of order. It's just spotting where the sequence broke.