What is debugging?
What is debugging?
Debugging is when you find an issue in the program that you have written and repair it. We would normally do this by using something called a debugging cycle.
When writing a program it is very easy to make mistakes in your code. Before reading this debugging guide it is advised that you read What is a program?, which explains the steps that are taken when building a program.
How children learn about debugging in KS1
In KS1 your child will learn to debug programs using real-world examples of algorithms.
For example, your child may be given a sequence of steps to complete in order to achieve a given task, such as brushing their teeth. The algorithm that your child is given may be incorrect and they will be asked to identify the problem. Have a look at the following example of a brushing-teeth algorithm:
The algorithm defines 6 steps that are required to be run in order to complete the task of brushing your teeth. However, if you read through the steps one at a time, you will see that Step Three says to put the toothbrush in your mouth and Step Four tells you to put toothpaste on the brush – they are in the wrong order. This is an error in our algorithm and will stop us from successfully completing the task. The process of finding and correcting errors in computer programs is known as debugging.
How children learn about debugging in KS2
At KS2 the idea of debugging is built upon to include reference to writing code, however the underlying processes do not change: you find out what is wrong with your program and then you work out how to fix it.
Your child will be introduced to the debugging cycle, and whilst there is no exact definition of the steps in the debugging cycle a good example can be seen below:
As you can see in the diagram, debugging is not a one-off task. If you have a small program with limited steps, it is easy to debug. However, in the real world, programs such as Microsoft Word and websites such as Facebook are so large that it is impossible to find all the bugs in the program. It is also important to note that often by fixing a bug in a program you introduce more bugs!
Why is correcting errors in programming called debugging?
The term debugging seems a strange one to use to describe the fixing of errors in a program. Why do we call errors computer bugs in the first place? The answer harks back to the 1940s when renowned computer programmer Grace Hopper recorded the first-ever instance of a computer bug. The Harvard Mark II computer was an early electronic computer and used electronic relays to make calculations. When Grace ran her program, she consistently got incorrect results and had to try to identify the problem. Through further investigation it was discovered that a moth had flown into one of the electronic relays, short-circuiting the computer and producing incorrect results. Thus, the first ever-recorded instance of a computer bug was found! Here it is in the logbook from 1947:
Debugging in primary school: what your child learns year-by-year
Please note that the following guidelines for what is taught in each primary year is for guidance only and may not be representative of the way computing is taught at your child’s school.
Introduction to the basic concept of debugging and how it is used to fix broken algorithms.
Students will have to debug basic algorithms for everyday tasks such as brushing your teeth.
Students may be given a program for a programmable floor robot and have to find an error in it.
Students will be given an algorithm in a visual programming language such as Scratch and have to debug it.
Year 5 and Year 6
From Y4 onwards students should be writing their own code in a visual language such as Scratch, and debugging will mainly be fixing bugs in their own code as opposed to searching for bugs in code given to them.