Lesson 4: Debugging with Scrat
Bug | Debugging | Scrat | Ice Age
Debugging is an essential element of learning to program. In this lesson, students will encounter puzzles that have been solved incorrectly. They will need to step through the existing code to identify errors, including incorrect loops, missing blocks, extra blocks, and blocks that are out of order.
Students in your class might become frustrated with this lesson because of the essence of debugging. Debugging is a concept that is very important to computer programming. Computer scientists have to get really good at facing the bugs in their own programs. Debugging forces the students to recognize problems and overcome them while building critical thinking and problem solving skills.
Warm Up (15 min)
Main Activity (30 min)
Wrap Up (5 - 10 min)
Students will be able to:
- Predict where a program will fail.
- Modify an existing program to solve errors.
- Reflect on the debugging process in an age-appropriate way.
- Play through the Course F Online Puzzles - Website to find any potential problem areas for your class.
- (Optional) Pick a couple of puzzles to do as a group with your class.
- Review CS Fundamentals Main Activity Tips - Lesson Recommendations.
- Make sure every student has a Think Spot Journal - Reflection Journal.
- Review Debugging Recipe - Student Handout with the class.
For the Teacher
- CS Fundamentals Main Activity Tips - Lesson Recommendations
For the Students
- Bug - Part of a program that does not work correctly.
- Debugging - Finding and fixing problems in an algorithm or program.
Warm Up (15 min)
Ask students to think about problems they have to solve in everyday life.
- How do you fix something that isn't working?
- Do you follow a specific series of steps?
- The puzzles in this unit have already been solved for you (yay!), but they don't seem to be working (boo!)
- We call the problems in these programs "bugs," and it will be your job to "debug" them.
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.
Debugging is a process. First, you must recognize that there is an error in your program. You then work through the program step by step to find the error. Try the first step, did it work? Then the second, how about now? If you make sure that everything is working line by line, then when you get to the place that your code isn't doing what it's supposed to, you know that you've found a bug. Once you've discovered your bug, you can work to fix (or "debug") it!
If you think it will build excitement in the class you can introduce the character of today's puzzles, Scrat from Ice Age. If students aren't familiar with Scrat, show some videos of the quirky squirrel running into trouble.
Main Activity (30 min)
Before letting the students start on the computer, remind them of the advantages of Pair Programming - Student Video and asking their peers for help. Sit students in pairs and recommend they ask at least two peers for help before they come to a teacher.
As mentioned in the purpose of this lesson, make sure the students are aware that they will face frustrating puzzles. Tell them it is okay to feel frustrated, but it is important to work through the problem and ask for help. As the students work through the puzzles, walk around to make sure no student is feeling so stuck that they aren't willing to continue anymore.
Wrap Up (5 - 10 min)
Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and build a review sheet for them to look to in the future.
- What was today’s lesson about?
- How did you feel during today’s lesson?
- What kind of bugs did you find today?
- Draw a bug you encountered in one of the puzzles today. What did you do to "debug" the program?
Use these activities to enhance student learning. They can be used as outside of class activities or other enrichment.
Have students go back through previous levels, purposefully adding bugs to their solutions. They can then ask other students to debug their work. This can also be done with paper puzzles.
When other students are debugging, make sure that the criticisms are constructive. If this could be a problem for your class, go over respectful debugging before this activity by role playing with another student.
CSTA K-12 Computer Science Standards
AP - Algorithms & Programming
- 1B-AP-08 - Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
- 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
This list represents opportunities in this lesson to support standards in other content areas.
Common Core English Language Arts Standards
L - Language
- 5.L.6 - Acquire and use accurately grade-appropriate general academic and domain-specific words and phrases, including those that signal contrast, addition, and other logical relationships (e.g., however, although, nevertheless, similarly, moreover, in addition).
SL - Speaking & Listening
- 5.SL.1 - Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 5 topics and texts, building on others’ ideas and expressing their own clearly.
- 5.SL.1.a - Come to discussions prepared, having read or studied required material; explicitly draw on that preparation and other information known about the topic to explore ideas under discussion.
- 5.SL.4 - Report on a topic or text or present an opinion, sequencing ideas logically and using appropriate facts and relevant, descriptive details to support main ideas or themes; speak clearly at an understandable pace.
- 5.SL.6 - Adapt speech to a variety of contexts and tasks, using formal English when appropriate to task and situation.
Common Core Math Standards
MP - Math Practices
- MP.1 - Make sense of problems and persevere in solving them
- MP.2 - Reason abstractly and quantitatively
- MP.4 - Model with mathematics
- 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
Next Generation Science Standards
ETS - Engineering in the Sciences
ETS1 - Engineering Design
- 3-5-ETS1-1 - Define a simple design problem reflecting a need or a want that includes specified criteria for success and constraints on materials, time, or cost.
- 3-5-ETS1-2 - Generate and compare multiple possible solutions to a problem based on how well each is likely to meet the criteria and constraints of the problem.
- 3-5-ETS1-3 - Plan and carry out fair tests in which variables are controlled and failure points are considered to identify aspects of a model or prototype that can be improved.