Lesson 1: Debugging: Unspotted Bugs
Bug | Debugging | Persistence | Unplugged
This lesson will guide students through the steps of debugging. Students will learn the mantra: "What happened? What was supposed to happen? What does that tell you?"
Research shows that some students have less trouble debugging a program than writing one when they first learn to code. In this lesson, we introduce the idea of debugging in a real world sense.
The goal in this lesson is to teach students steps to spot a bug and to increase persistence by showing them that it's normal to find mistakes. In later lessons, students will debug actual programs on Code.org.
Warm Up (12 min)
Marble Run Breakdown (10 - 20 min)
Wrap Up (10 - 20 min)
Students will be able to:
- Express that they have noticed when something goes differently than what is expected.
- Identify what the expected result was before an error occurs.
- Determine and describe the difference between what was expected and what actually happened in the event of an error.
- Watch the Unspotted Bugs - Teacher Video.
- Review the Unspotted Bugs Story (Unspotted Bugs - Online Story)
- Pre-read Unspotted Bugs to identify appropriate questions for your classroom
- Follow instructions in the Marble Run - Teacher Prep Guide to make a Marble Run (which will be arranged incorrectly at the start)
- Give a Think Spot Journal - Reflection Journal to each student
For the Teacher
For the Students
- Feeling Faces - Emotion Images
- Unspotted Bugs - Online Story
- Think Spot Journal - Reflection Journal
- Bug - Part of a program that does not work correctly.
- Debugging - Finding and fixing problems in an algorithm or program.
- Persistence - Trying again and again, even when something is very hard.
Warm Up (12 min)
Goal: Help students understand the steps involved in debugging.
This story can be presented in several ways, including:
- Circled up story time
- Projected with document camera / smartboard
- Pair shared with students at their computers
Important ideas from the story:
- What happened?
- What was supposed to happen?
- What does that tell you?
- Did it work at the first step?
- Did it work at the second step?
- Where did it go wrong?
The story of Unspotted Bugs presents many of the ideas that students will need to understand the debugging process of coding. This warm-up is meant to tie a memorable story together with a concept that young kids often find to be difficult.
Read the book and discuss the techniques that JD used to discover and take care of bugs. Make sure those questions and tactics get repeated often enough that students can recall (if not recite) them without the story in hand.
Potential Questions for Storytime:
- Page 3: What do you notice in the picture? What’s wrong with the flower? (It’s upside down!) What’s wrong with the clock? (The hands aren’t in the center) Why do you think there is something wrong with these items?(Because there are bugs on them!)
- Page 7: What’s wrong with the picture? (The lamp is upside down) Why is that? (There’s a bug)
- Page 11: What’s wrong in this scene? (The car doesn’t have wheels!) Why? (Because there are bugs on it!)
- What did JD find when he went looking for the bug? What was wrong? What does this mean? (JD found an upside down tree. This is wrong because the tree trunk should be touching the ground! This means there is a bug on the tree!)
This lesson has three new and important vocabulary words:
Bug - Say it with me: Buhh-g. Something that is going wrong. An error.
Debugging - Say it with me: Dee-bug-ing. To find and fix errors.
Persistence - Say it with me: Purr-siss-tense. Not giving up. Persistence works best when you try things many different ways, many different times.
Marble Run Breakdown (10 - 20 min)
Goal: Help students think critically about the difference between what is happening and what is expected.
Debug the Run
Great! You all are so good at this, maybe you can help me with my own problem!
See, I have this marble run that I made. It comes in two pieces. When I put the ball in here (input A) it’s supposed to come out here (output A). When I put the ball in here (input B) it’s supposed to come out here (output B). Now, when I slide them together, I should be able to put the ball in here (input A) and have it come out here (output B). But it doesn’t work, watch.
[Slide the pieces together with output B facing output A.]
Watch what happens. [Drop ball at input A and notice that it does not come out output B.]
- The ball fell on the table.
What was supposed to happen?
- The ball was supposed to drop from A into B.
What does that tell you?
- You should turn B around so that the ball goes into the right place!
Now that students have been introduced to the idea of looking for problems, they can try to apply it to more places in the real world. This next activity gives them practice looking for bugs in Marble Runs (a project that they will be working with next week.)
Grab your sample marble run (built from our plans, or something similar.) Show the students how each piece works, then demonstrate putting them together (but put them together incorrectly, to prevent the ball from flowing properly from A to B.
The goal of this exercise is to help the students identify when something goes wrong, so if they don’t catch it the first time, run it again, and again. It can help to make exaggerated frustration faces when the ball doesn’t do what you would like it to do.
Let the students share hypotheses about what is going wrong, and how to fix it. Students should feel free to try things that you know will be incorrect. If students misidentify solutions, use the bug finding formula on their configurations. Repeat until you get a working run.
Encouragement is key here. If things don’t work right away, praise the class for being so persistent and choosing not to give up. If they start to get frustrated, encourage them to persist a bit longer, promising them that they will get it soon if they just hang in there.
Wrap Up (10 - 20 min)
Goal: Students will start to understand the importance of the activity they just completed by reflecting on it verbally, then through drawing in their journals.
What do you think we learned in this lesson?
- How to solve a problem
- How to make a marble go
- How do you think that can help us in other places?
Clear your mind:
It can be distracting to a learner when they have unanswered questions or doubts. To end this lesson, we’ll give everyone the chance to get those out so that they can reflect on what they’ve been taught.
Encourage students to share their thoughts and questions either with the whole class or with an elbow partner.
Once they’ve had time to ponder their own thoughts, get the students thinking about the purpose of the lesson that they just learned. Why did you do this activity? How will it help them later? Can they think of buggy things that they’ve seen in the real world?
Students should finish by drawing or writing in their journal. Possible topics include:
- Draw one of the Feeling Faces - Emotion Images that shows how you felt about today's lesson in the corner of your journal page.
- How do you feel when something that you are working on acts buggy?
- How many times do you think you should try to fix a bug before you give up?
- What would you do if you notice that something is buggy, but you don't know how to fix it?
The signs of real-live bugs won’t be as dramatic as upside down trees, but it might be dead leaves, spots on flowers, or slime on the
sidewalk. Have the students brainstorm these before going outside to look for them.
Real Life Bug Hunting
Take your students outside. Do you see any signs of bugs? What are they? Now look closer... can you find the actual bug?
Common Core English Language Arts Standards
RL - Reading Literature
- K.RL.10 - Actively engage in group reading activities with purpose and understanding.
- K.RL.7 - With prompting and support, describe the relationship between illustrations and the story in which they appear (e.g., what moment in a story an illustration depicts).
SL - Speaking & Listening
- K.SL.1 - Participate in collaborative conversations with diverse partners about kindergarten topics and texts with peers and adults in small and larger groups.
- K.SL.2 - Confirm understanding of a text read aloud or information presented orally or through other media by asking and answering questions about key details and requesting clarification if something is not understood.
Common Core Math Standards
G - Geometry
- K.G.5 - Model shapes in the world by building shapes from components (e.g., sticks and clay balls) and drawing shapes.
MD - Measurement And Data
- K.MD.1 - Describe measurable attributes of objects, such as length or weight. Describe several measurable attributes of a single object.
MP - Math Practices
- MP.1 - Make sense of problems and persevere in solving them
- MP.2 - Reason abstractly and quantitatively
- MP.3 - Construct viable arguments and critique the reasoning of others
- MP.5 - Use appropriate tools strategically
- MP.6 - Attend to precision
- MP.7 - Look for and make use of structure
- MP.8 - Look for and express regularity in repeated reasoning
CSTA K-12 Computer Science Standards
AP - Algorithms & Programming
- 1A-AP-11 - Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions.
Next Generation Science Standards
ETS - Engineering in the Sciences
ETS1 - Engineering Design
- K-2-ETS1-1 - Ask questions, make observations, and gather information about a situation people want to change to define a simple problem that can be solved through the development of a new or improved object or tool.
- K-2-ETS1-2 - Develop a simple sketch, drawing, or physical model to illustrate how the shape of an object helps it function as needed to solve a given problem.
- K-2-ETS1-3 - Analyze data from tests of two objects designed to solve the same problem to compare the strengths and weaknesses of how each performs.