Overview

In this lesson students practice using the different programming concepts that they were introduced to in the last lesson. To begin, however, they are introduced to the concept of debugging and are encouraged to use and reflect on this practice throughout the lesson. At the end of the lesson students share their experiences debugging as well as an new realizations about programming.

Goals

Students will be able to:

Purpose

This lesson serves a number of roles. Even if students had modified programs in the previous lesson, this continues to be an introduction to many of the skills of programming. Students are also introduced to debugging as a skill they'll need to use and develop as programmers. A huge goal of this lesson, however, is attitudinal.

Resources

Getting Started

Prompt: Your friend calls you and says "I can't get music to come out of my speakers, can you help?" Write a quick list of everything you'd ask them or have them check to try to fix the problem.

Optional Warmup Prompt: This prompt is optional and included for instances where you need a warm up prompt on the board when students walk in. If your classroom is able to move directly to main activity you should feel free to skip this prompt in the interest of time.

Discussion Goal: This prompt should help get students in the mindset of debugging. If students ask for more details tell them that this is all the information they have and that they should work with what they know -- or figure out what questions they could use to learn more information about the problem.


Remarks

Activity

Understanding the Debugging Process

Display: Show the How to Debug Video. Then, share the 4 steps of the debugging process:

  1. Describe the Problem
    • What do you expect it to do?
    • What does it actually do?
    • Does it always happen?
  2. Hunt for Bugs
    • Are there warnings or errors?
    • What did you change most recently?
    • Explain your code to someone else
    • Look for code related to the problem
  3. Try Solutions
    • Make a small change
  4. Document as You Go
    • What have you learned?
    • What strategies did you use?
    • What questions do you have?

Remarks

Practice Time

Group: Place students in pairs.

App #1

Open a Project: Have students open the "Lesson7_App1" project. In the SourceCode folder, students should open "Main.quorum".

Activity: There's an error in the code that stops this code from running. Students should debug this program by fixing the error.

Outcomes: This challenge requires students to recognize that strings need to go in quotes.


App #2

Open a Project: Have students open the "Lesson7_App2" project. In the SourceCode folder, students should open "Main.quorum".

Activity: This program also doesn't run. Debug the program.

Outcomes: This challenge also requires students to recognize that strings need to go in quotes. Ideally students will get more familiar with the red underlines highlighting errors in Quorum Studio.


App #3

Open a Project: Have students open the "Lesson7_App3" project. In the SourceCode folder, students should open "Main.quorum".

Activity: Run this app to see how it works. Then debug the program to use the correct sound and text when the user clicks each animal button.

Outcomes: The code in this challenge will run, but the wrong text and sounds have been placed in the wrong places. There is also a typo that prevents the rooster button from activating code. This shows that code may have no warnings but still is not working correctly.


App #4

Open a Project: Have students open the "Lesson7_App4" project. In the SourceCode folder, students should open "Main.quorum".

Activity: Run this program to see how it works. Then debug the program so that the smiley face doesn't go off the screen when the user uses either the mouse or keyboard.

Outcomes: Again this code has no warnings but in testing the app students should see that the range of values for the random numbers is too large. Iterative testing with different values should help them pick a number that keeps the smiley inside the screen. It's also possible to deduce "good" values by considering the size of the screen and the size of the smiley face.


App #5

Open a Project: Have students open the "Lesson7_App5" project. In the SourceCode folder, students should open "Main.quorum".

Activity: Run this program to see how it works. Then add code to the program so that the "Go Back" button takes the user back to the home page.

Outcomes: In this level an entire event handler is missing. Students will need to add it to the app.


App #6

Open a Project: Have students open the "Lesson7_App6" project. In the SourceCode folder, students should open "Main.quorum".

Activity: Run this program to see how it works. Then add code to the app to make the "Excited" button work.

Outcomes: This app is a good chance for students to practice adding functionality of their own. While nothing starts off as "broken", students will need to use debugging practices as they add code to this app.

Wrap Up

Prompt: If you were using the debugging process then you should have some notes of good debugging tips. Share those with your neighbor and add any new ones you forgot to add. Be ready to share with the class.

Discussion Goal: This discussion should help reinforce the fact that debugging is a skill that can be learned and that it is made up of many little steps and understandings. Give the room an opportunity to share as many ideas as they can before sharing the recommended steps.

Do This: Share these best practices in addition to those students may have mentioned:

  1. Keep your code clean
    • User clear, meaningful IDs for your elements
    • Keep your code organized in chunks that do the same thing
    • Use comments to explain your code
  2. Run your code
    • Run your code a lot, every time you add a command or two
    • Use output statements throughout your code to get feedback on what parts are running.
  3. Use classmates and resources
    • Talk out the problems with a partner or classmate
    • Compare your code to examples that you know work
    • Read documentation to know how code is supposed to work
    • Hand trace your code to track what's happening

Remarks

Journal: Have students add the following vocabulary words and definitions to their journals:


Remarks

Assessment: Check for Understanding

Question: What is one thing you really enjoyed about today's activity?

Question: Is there anything that you found confusing or need extra help with?

Standards Alignment