Skip to content
Computer Science · Grade 12

Active learning ideas

Debugging and Error Handling

Active learning works because debugging requires hands-on problem-solving rather than passive observation. Students learn best when they wrestle with real bugs, compare strategies, and explain their choices to peers. These activities force them to move from guessing to systematic investigation, which builds lasting debugging habits.

Ontario Curriculum ExpectationsCS.SE.10CS.P.26
20–45 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning30 min · Pairs

Pair Debug Relay: Hidden Bug Chain

Provide pairs with code containing three linked bugs. Partner A runs tests and notes failures; Partner B proposes fixes using IDE tools, then they switch roles. Pairs log steps and share one key insight with the class.

Explain systematic approaches to debugging complex software issues.

Facilitation TipBefore starting Pair Debug Relay, assign specific roles (e.g., reader, debugger) to ensure both students engage with the hidden chain.

What to look forProvide students with a small, intentionally buggy code snippet. Ask them to identify the bug and describe the specific debugging technique (e.g., breakpoint, print statement) they would use to find it, explaining why that technique is suitable.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning45 min · Small Groups

Small Group: Error Strategy Duel

Groups implement the same function twice: once with exceptions, once with return codes. Introduce failures like invalid inputs, time which handles better, and vote on trade-offs. Present findings via posters.

Compare different error handling strategies (e.g., exceptions, return codes).

Facilitation TipIn Error Strategy Duel, set a strict 5-minute timer for each strategy to prevent over-analysis and force quick decision-making.

What to look forPresent two scenarios: one where an unexpected input might cause a program to crash (e.g., dividing by zero) and another where a predictable but invalid input is provided (e.g., negative age). Ask students to discuss which error handling strategy (exception vs. return code) is more appropriate for each scenario and why.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning25 min · Whole Class

Whole Class: Live Bug Hunt Poll

Display buggy code on a shared screen. Poll the class for next debug step (breakpoint, log, refactor), implement votes, and trace execution together. Debrief on why certain paths succeeded.

Design a robust error handling mechanism for a critical section of code.

Facilitation TipFor Live Bug Hunt Poll, prepare 3-4 buggy snippets of varying difficulty so all students can participate without frustration.

What to look forStudents work in pairs to debug a shared piece of code. After finding and fixing a bug, they explain their debugging process to another pair, detailing the steps taken and the reasoning behind their chosen approach. The second pair provides feedback on the clarity and efficiency of the debugging strategy.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning20 min · Individual

Individual: Personal Code Audit Log

Students select their project code, plant three errors, then debug using a template log for steps, tools used, and resolutions. Submit logs for peer review next class.

Explain systematic approaches to debugging complex software issues.

Facilitation TipDuring Personal Code Audit Log, model how to log assumptions and dead-ends, not just successes, to normalize the debugging process.

What to look forProvide students with a small, intentionally buggy code snippet. Ask them to identify the bug and describe the specific debugging technique (e.g., breakpoint, print statement) they would use to find it, explaining why that technique is suitable.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Teach debugging as a mindset, not a checklist, by emphasizing that students must slow down to speed up. Research shows that explicit comparison of strategies reduces cognitive load, so always pair techniques with the types of errors they handle. Avoid letting students fixate on one tool; instead, rotate tools to build flexibility.

Successful learning looks like students replacing trial-and-error with structured debugging steps, justifying their tool choices, and transferring strategies across different code contexts. They should articulate why certain techniques fit specific errors and revise their approaches based on peer feedback.


Watch Out for These Misconceptions

  • During Pair Debug Relay, watch for students who rely solely on printing values without stepping through code or using debuggers.

    Require partners to alternate between print statements and breakpoints each time they encounter a new bug, forcing them to compare the insights each tool provides.

  • During Error Strategy Duel, watch for students who default to exceptions for every scenario without considering performance or predictability.

    Provide a side-by-side comparison chart of exceptions versus return codes for each duel scenario, then ask students to justify their choice in a one-sentence summary before coding.

  • During Live Bug Hunt Poll, watch for students who assume bugs are random and ignore patterns in input boundaries or loop conditions.

    After each poll response, ask the class to list three common patterns they noticed in the bugs, then revisit the same patterns in the next snippets to reinforce recognition.


Methods used in this brief