Recent posts View all
Home of real teaching & learning
  • Full support for teachers
  • Focus on critical thinking
  • Engaging classroom activities
  • Integrated student eBook
  • Assessed tasks / qBank
  • Practice exam questions

The InThinking Guarantee: Our sites are written by expert practitioners and not by AI

See our AI policy

Disclaimer: InThinking subject sites are neither endorsed by nor connected with the International Baccalaureate Organisation.

Don't miss out, find out!
IB Approved Workshops

Computer Science
IB DP Category 1

Paris, France, 13 - 15 November 2026

Find out more
Computer science (New Syllabus)
IB DP Category 2

Paris, France, 19 - 21 February 2027

Find out more

Find all InThinking events at
inthinking.net

Why fixing bugs is better than writing code

Shifting the focus from syntax to logic in the IB Computer Science classroom.

We have all been there. You introduce a new programming concept like while loops, and give your students a blank screen and a prompt: "Write a program that counts to ten." Five minutes later, half the class is staring at a blinking cursor, and the other half has written print("1, 2, 3, 4...").

When we ask beginners to write code from scratch, we are asking them to do three difficult things simultaneously:

  1. Recall Syntax: Remembering where the colons and parentheses go.
  2. Structure Logic: figuring out the algorithmic steps.
  3. Solve the Problem: Apply that logic to the specific task.

It is often too much. The result? Frustration, copy-pasting, and very little actual learning.

The Bug-Fixing approach is often a better way to develop skills and computational thinking. Instead of asking students to build, ask them to repair. By giving students code that is syntactically correct but logically flawed, we strip away the stress of syntax errors. They don't have to worry about missing semicolons or indentation.

Instead, they can focus entirely on the Computational Thinking:

  • Tracing: "What does this variable actually hold right now?"
  • Logic: "Why is the loop stopping at 9 instead of 10?"
  • Debugging: "How do I fix it?"

This approach mirrors the real world. Professional developers spend far more time reading and debugging code than they do writing new functions from scratch.

Here is a resource I successfully used last term to introduce Topic B2.4 (Algorithms). It covers the Bubble Sort, a classic algorithm that students often memorise but rarely fully understand.

The code below runs without crashing, but it doesn't sort the list correctly.

  • The Goal: Find the logic error.
  • The Hint: Look at the inner loop range.

Why This Works: This simple exercise forces students to trace the swap logic. They quickly realise that arr[j] = arr[j+1] overwrites the data before it can be saved. They have to "invent" the temporary variable solution themselves. That "Aha!" moment is far more potent than copying a perfect algorithm from the board.

We have developed a full suite of these "Broken Code" Challenges covering Topic B2. 

Subscribers can access the full interactive pack, complete with solution keys and teacher notes, on each main sub-topic page:

B 2.1 Programming Fundamentals 

B 2.2 Data structures 

B 2.3 Programming constructs 

B 2.4 Programming algorithms 

B 2.5 File Processing 

Stop teaching syntax. Start teaching logic.

Help