How I teach - A devious method to crack code

14th March 2014 at 00:00
Students debug programming lessons by becoming saboteurs

When I shout "Sabotage!" in my classroom, it is not because a staffroom rival has been messing about with my interactive whiteboard. Instead, it is to begin a game I devised to teach my information communications technology students how to debug their own programming.

When I first switched from teaching Scratch (a visual programming language) to teaching Python (a text-based programming language), I found that students quickly became frustrated by the high number of syntax errors that prevented their scripts from working. This created negative associations with text-based programming, as there was a much higher failure rate than with Scratch.

Many children were derailed at the first hurdle, and resorted to either giving up completely or raising their hand and waiting for me to attend to them like a repair man. But helping them was counterproductive: others realised that if they got stuck, they could also put their hands up and wait for roadside assistance to arrive.

This behaviour spread around the classroom, and soon I was faced with a crop of raised hands. I knew that this situation was unsustainable, and it was down to me to change it.

First, I tried getting the students to fix the issues themselves. However, this did not encourage them to solve their problems independently and, in some cases, it made them all the more exasperated. Thankfully, at last I had a light-bulb moment: the game of Sabotage. It works like this:

  1. Each student starts with a script for a game, and we test the game to make sure that it works.
  2. I ask every child in the class to think of examples of syntax errors that might prevent the game from working properly. With a partner, they share as many of these as they can in one minute. Then they form groups of four to see if they can find any more examples.
  3. I compile a list of generic examples by asking each group to suggest one typical error.
  4. I explain to the class that they are going to deliberately sabotage their partner's working code by hiding five errors in there - no more, no less. I suggest that one error should be pretty obvious and one should be very sneaky: using the character 0 instead of the letter O, for example.
  5. Working in their pairs, one student sabotages the code. That student then has to give hints and clues to help their partner debug the errors that have been introduced. Then the students swap roles.
  6. We end the game with discussion. Which students managed to debug all five errors? Who introduced the most sneaky errors? What were they? Who gets the prize for being the most helpful? Who gets the prize for being the most devious?
    1. Not only does the game of Sabotage help students to spot errors in their own code but it also encourages them to turn to their peers for assistance more often. Their enjoyment and engagement is clear as they slyly hide errors in the code and rejoice as they discover the traps that their partner has planted.

      Alan O'Donohoe (@teknoteacher) is principal teacher of computing at Our Lady's Catholic High School in Preston, in Lancashire in the North West of England. He is a Computing At School master teacher and the founder of Raspberry Jam. Read more from Alan at: about.mealanodonohoe

      Top 10 programming and coding resources

      1. Unseen mechanics

      Get your students up to speed on website design with this introduction to HTML and how it forms the structure of a website.

      2. Crack coding

      Greeted by a sea of blank faces when you talk about coding? Guide your students through its importance and numerous real-world uses with these lesson plans.

      3. Learn the lingo

      Try a short video guide discussing online terms such as cookies, sessions, file uploads and file-handling systems.

      4. Scratch that

      These learning mats for programming language Scratch offer a handy way of introducing coding skills to primary students.

      5. Own goals

      Encourage independent learning in your classroom: this booklet introduces students to Visual Basic programming and allows them to work things out at their own pace.

      6. Sing the signs

      This lesson uses pop songs to introduce students to the workings of inputs and outputs in programming language.

      7. Practice Python

      An extensive guide to using Python coding in the classroom, plus a series of challenging tasks for students.

      8. Starter code

      These adaptable flash cards contain basic codes and instructions to help beginners get started with Raspberry Pi.

      9. Coded components

      Break down the elements of a game built in Scratch using this how-to video guide, deconstruction exercises and a PowerPoint to support whole-class teaching.

      10. Web worksheets

      Teach your students about web pages, HTML and CSS with this collection of hand-outs.


Get TES online and delivered to your door – for less than the price of a coffee

Save 33% off the cover price with this great subscription offer. Every copy delivered to your door by first-class post, plus full access to TES online and the TES app for just £1.90 per week.
Subscribers also enjoy a range of fantastic offers and benefits worth over £270:

  • Discounts off TES Institute courses
  • Access over 200,000 articles in the TES online archive
  • Free Tastecard membership worth £79.99
  • Discounts with Zipcar,, Virgin Wines and other partners
Order your low-cost subscription today