Αρχική » Computational Thinking » Barefoot Debugging approach

Barefoot Debugging approach

debugging

What is debugging?

Bugs are errors in algorithms and code. Debugging is the process of finding and fixing these and it can often take much longer than writing the code in the first place. There can be errors or in logic and syntax. We can think of errors in logic as parts of a story where the plot doesn’t make sense, and errors in coding and syntax as poor spelling, punctuation and grammar. When debugging, it can be useful to display the contents of any variables in our program, to help us understand what’s going on as it runs.

We suggest a simple sequence of four steps to debugging, underpinned by logical reasoning:

1. Predict what should happen.
2. Find out what does happen.
3. Work out where something has gone wrong.
4. Fix it.

The first computer bug is said to have been a real moth, found in 1947 trapped between points in a relay of a calculator being tested at Harvard University. The operator who found the bug taped it to the computer log, with the entry: “First actual case of bug being found.”

A photo of the moth which is reputed to have been the first "computer bug".

The first computer bug. Image by courtesy of the Naval Surface Warfare Center, Dahlgren, Virginia, USA, 1988 (public domain, via Wikimedia Commons).

Although she did not find the famous moth, Grace Hopper made the term “debugging” popular. Grace was a pioneering computer scientist of her time and a programmer of one of the earliest computers, the Harvard Mark 1. She developed the first compiler, a special type of program to convert the programs written by humans into the 0s and 1s understood by a computer. This paved the way for the development of modern programming languages.

A photo of Grace Hopper.

Grace Hopper popularised the term “debugging”. Image from the US Naval Historical Center Online (public domain).

Why is debugging important?

The complex code which programmers write often doesn’t work as intended straightaway. There are widely varying claims about the amount of effort, time and money expended on debugging in commercial projects. Hailpern and Santhanam’s paper, “Software debugging, testing and verification”, reported that debugging and testing activities account for 50–75% of project costs.

What does debugging look like in the classroom?

Pupils focussed on writing a program might want help fixing problems. It’s worth explaining to them that the objective is not necessarily to get a working program but to learn how to program; their own ability to debug is a big part of that. A helpful approach is for them to explain their algorithm and code to someone else, or even just something else – such as a rubber duck! The process of describing what a program should do, line by line, is called rubber-duck debugging and it’s quite likely that, simply through the process of forming their explanation, pupils will spot any problems themselves. Debugging can be easier if done along the way (sometimes referred to as testing), rather than after lots of code has been written. Model how to debug short portions of code, even just with programmable toys, because this establishes better habits for the future.

A photo of a rubber duck.

Young pupils may find it useful to talk to rubber ducks, to help themselves think through debugging.

Αλλαγή μεγέθους γραμματοσειράς
Αντίθεση