Learn Without Walls
← Back to Module 6

Module 6: Study Guide

Review the key concepts from Debugging: Finding and Fixing Mistakes. Use this before the quiz or anytime you want a refresher!

Big Ideas

Everyone makes mistakes. Even the best coders in the world make errors every single day. Mistakes are not a sign that you are bad at something. They are a sign that you are learning.
A bug is a mistake or error that makes something not work the way you expected. The word comes from a real moth that got stuck in a computer in 1947, found by Grace Hopper and her team.
Debugging means finding and fixing bugs. You are like a detective -- you look for clues, check things one at a time, and figure out what went wrong.
Growth mindset means believing you can get better at anything through effort and practice. The magic word is "yet" -- "I cannot do it yet" means you are on your way.

The 4 Debugging Detective Steps

  1. What did you expect to happen? Say it out loud before you look for the bug.
  2. What actually happened? Be specific! Not "it does not work" but exactly what went wrong.
  3. Check one thing at a time. Go through each step from the beginning. Stop when you find something wrong.
  4. Change one thing, then test. Fix what you found and see if it works. If not, undo and try the next thing.

Remember!

Never change two things at once. If you do and it starts working, you will not know which change actually fixed the problem.

The 3 Most Common Bug Types

1. Wrong step: One of the steps has the wrong information. Like saying "turn left" when you meant "turn right," or using the number 80 when you meant 90.
2. Missing step: A step is completely left out. Everything else is correct, but something is missing. Like forgetting to add sugar to lemonade.
3. Wrong order: All the steps are there and correct, but they are in the wrong sequence. Like putting on shoes before socks.

Quick Check

When debugging, ask yourself: "Is a step wrong? Is a step missing? Are the steps in the wrong order?" One of these three is almost always the answer.

Debugging Tips

Check the simple stuff first. Is it plugged in? Is the switch on? Did you spell it right? Did you save your work? The problem is often simpler than you think.
Rubber duck debugging: Explain your problem out loud, step by step, to someone or something (even a stuffed animal). Saying it out loud often helps you hear what you missed.
When stuck, take a break. Walk away for five minutes. Your brain keeps working on the problem even when you are not thinking about it. Come back with fresh eyes.
Asking for help is smart. It is not giving up. Two brains are better than one!

The 5 Most Common Scratch Bugs

1. Missing "when green flag clicked" -- The code has no event block on top, so Scratch does not know when to start.
2. Blocks not connected -- Some blocks are floating separately instead of snapped together in a stack.
3. Wrong numbers -- The blocks are right but the numbers inside them are wrong (too big, too small, or the wrong value).
4. Wrong sprite selected -- You are adding blocks to the wrong sprite. Always check which sprite is highlighted.
5. Sprite is hidden or off screen -- The code runs but you cannot see it because the sprite is invisible or moved off the stage.

Review Questions

1. What is a bug?

A bug is a mistake or error that makes something not work the way you expected. The word comes from a real moth found in a computer in 1947.

2. What are the 4 Debugging Detective steps?

(1) What did you expect? (2) What actually happened? (3) Check one thing at a time. (4) Change one thing, then test.

3. What does "growth mindset" mean?

Growth mindset means believing you can get better at anything with effort and practice. Mistakes are chances to learn, not reasons to quit. The word "yet" helps: "I cannot do it yet."

4. What are the 3 most common types of bugs?

(1) A wrong step -- incorrect information. (2) A missing step -- something left out. (3) Wrong order -- correct steps in the wrong sequence.

5. What is rubber duck debugging?

Explaining your problem out loud, step by step, to someone or something (like a rubber duck or stuffed animal). Saying it out loud helps you discover what you missed. Professional coders really use this!

6. Your Scratch code does not run when you click the green flag. What should you check first?

Check if there is a "when green flag clicked" block at the top of your stack. This is the most common reason code does not start -- Scratch needs an event block to know when to begin.

7. Why should you check the simple things first when debugging?

Because the problem is often something simple! Checking easy things first is fast and saves you from spending a long time looking for a complicated problem when the fix might be obvious.
Take the Quiz Back to Module 6