Skip to main content

Debugging

Grades: All
Estimated Duration: 11-20 minutes, 21-30 minutes, 30+ minutes

Table of Contents

Analyzing
Check for understanding, Inquiry, Practice
Any
Individual, pair, small group
App, Device, Software

Description

Debugging is the process of identifying a problem in code and fixing it. Debugging is an essential skill for programmers because encountering errors in code is an inevitable part of the programming process. Teaching students strategies for debugging may be challenging, but it is a critical component of learning to code. Debugging as a learning strategy not only supports stronger computer programming and computational thinking skills but also promotes problem solving and persistence in the face of challenges.

When To Use It

As a learning strategy, use debugging when you want students to:

  • develop strategies for investigating code errors and fixing them
  • follow a methodical thinking process for identifying and fixing errors in code
  • Develop patience and persistence in solving problems
  • recognize and learn from their mistakes

As an instructional strategy, use debugging when you want to:

  • address student misconceptions and errors in the coding process
  • teach students how to identify and fix code errors using appropriate scaffolding and nudging
  • develop students’ ability to recognize their mistakes and debug code independently
  • increase students’ ability to write successful computer programs

How To Use It

Advance Prep

Debugging can be taught through modeling with examples and continued practice. Since bugs may not be anticipated or planned, it is a process that is implemented when an error occurs. There is no magic bullet for debugging because errors in code can occur for a variety of reasons, and there are a variety of approaches to address different types of bugs. Teaching students how to think through the debugging process is just as important as teaching them how to address specific types of errors.

Advanced preparation for implementing debugging in your coding lessons may consist of a posted set of guidelines to help students approach a debugging scenario or deliberate lessons where students work through debugging scenarios.

When students encounter a bug in their code, encourage them to follow debugging strategies related to common programming errors, such as syntax errors, logic errors, compilation errors, arithmetic errors, runtime errors, resource errors, and interface errors.

Some general guidelines to share, model, and review with students might include:

  1. Review the project expectations to ensure that your program is written to solve the given problem.
  2. Try to identify the exact problem. Ask yourself: What happened? What should have happened? What does this tell you?
  3. Carefully examine what parts of the code are working and what is not. See if you can reproduce the problem. *If applicable, examine the error message that is generated from the program. This message will help identify the location of the error.
  4. Compare your code to previous projects or sample projects to see if you recognize an error. Use help pages or reference materials if they are available.
  5. Read over your code carefully to check for errors, including misspellings or incorrect numbers.
  6. Experiment with one fix at a time. Make one change at a time and rerun the program to see what happens before making multiple changes at once.
  7. Ask a classmate for a hint, but not the solution.
  8. If you’ve tried the strategies and are still facing errors, ask the teacher for help.

For teachers, knowing how much scaffolding to provide when supporting students with errors is critical for keeping students engaged in the coding process. Debugging can be a frustrating process for some students, causing them to disengage, while others might thrive on the challenge of seeking out and fixing errors. Knowing your students’ frustration thresholds is important when determining whether to guide students or give the solutions to help them proceed successfully with the coding project.

Implementation

  1. Share, model, and review general guidelines for approaching errors in code.
  2. Leverage “teachable moments” to address bugs that arise during programming projects. Use appropriate scaffolding to support students with solutions according to their specific needs.
  3. Integrate debugging lessons based on specific scenarios to give students practice with debugging skills. *Code.org and other K-12 coding websites have online debugging lessons for students to try.
  4. Debrief debugging processes with students to ensure that they have understood their errors and know how to fix them.

Pros

  • Supports stronger computational thinking and computer programming skills
  • Promotes persistence in problem solving
  • Develops a critical computer programming skill used in the real world
  • Promotes attention to detail and logical thinking

Cons

  • Can be frustrating for some students because it requires patience and persistence
  • Is difficult to teach because errors can occur for many reasons, and there are many ways to approach different types of errors
  • Errors in complex code can be difficult to identify
  • Can be a time-consuming process

Culturally Responsive Application

While debugging is not a culturally responsive practice, integrating it into computer science education aligns with a core component of the Kapor Center Framework for Culturally Responsive-Sustaining CS Education. The framework states that “Pedagogy and curriculum is rigorous — aligned to K-12 CS standards and high expectations are set for all students.” By including debugging in coding lessons, teachers are addressing an essential component of K-12 Computer Science standards and adding rigor to the coding process. Teaching all students how to debug equips them with the necessary skills to compete in the CS field and be successful computer programmers.

Emerging English Language Support

Educator may define program structure, instructor role, and clinical encounters to support the novice candidate as they move through stages of reflective practice using video (or any other technology).

Students with Disabilities Support

Dialogue journaling improve student teacher relationships and in turn improving student behavior is a benefit to the students, teachers, community, and parents. Research shows that if a student has one ally in a building they are more likely to have a successful educational experience.

Subjects

5.4 Algorithms & programming

Why It Works

Children that acquired debugging skills improved more on transfer tasks involving debugging written instructions (REF90), educators that teach learners self-reliance report fewer compile-time errors (REF91)