成人快手

What is debugging?

is an important process in developing and computer .

It involves testing the outcome of programs and looking for any errors or mistakes, either in the original algorithms or in the final program .

Back to top

Different types of bugs

Syntax bugs

The word syntax means the order of elements in a language sentence. The language can be a familiar one like English or a coding language.

A syntax bug is one that involves typing mistakes and errors in the symbols, letters and numbers used to write the code itself.

A syntax bug means the code doesn't make sense to the computer, so often the program will not run at all.

This program is written in the coding language called Logo. It is supposed to make the pointer draw a square with sides 100 units long.

Can you spot the syntax bug in the program?

Logic bugs

A logic bug is an error in the organisation or sequence of the algorithm or program instructions themselves.

Perhaps the programmer has written the wrong command, missed one out or put the instructions in the incorrect order.

A program with a logic bug is usually able to run and tries to carry out the instructions written in the code.

However, because the instructions are wrong, things don't turn out how the programmer intends!

Let's check what has happened with the shape this time.

Remember, it is supposed to be a square with sides 100 units long.

This time, the program has a logic bug. Can you spot it?

Watch: The differences between syntax bugs and logic bugs

Back to top

Where are the bugs hiding?

It's important to remember all the stages we go through to create a computer program. This will help us become better at debugging our algorithms and programs.

  • We start by breaking the task or problem up into smaller sections - decomposition.
  • Then we make a list of rules and instructions for the different parts of the task or problem - these are called algorithms.
  • Finally, we translate these algorithms into a language that a computer can understand - code.

Errors or can creep in at all these different stages so we will need to check them when we debug.

Back to top

The debugging and testing cycle

One of the main strategies for successful and efficient debugging, is to keep testing and debugging at all stages of a project, as we go along.

If we wait until the end, we will have to search through all the algorithm instructions and every bit of our program code, which could take a long time.

We know what our program is supposed to do. So, we can check to see if it works and if not, go back and debug and then test again.

The cycle of testing, debugging and testing again, is a key skill that we need to learn to become good computer programmers.

Back to top

Teamwork can defeat the bugs

We all know that problem solving is always easier with friends to help. It's the same with debugging.

Sometimes another person will spot a bug you might have missed and you might catch one that they didn't see.

Being able to work as part of a team is a useful skill for successful debugging. Computer programmers often work together in teams to debug complicated projects.

You can try it out with your classmates, friends and family as you learn to write your own computer program.

Back to top

Debugging in real life

When it comes to computer games, we all like to download new features and characters as soon as they come out.

Unfortunately, the first version of the updated program usually has a few bugs that slipped through the testing process.

This can lead to all sorts of problems like incorrect game controls, graphic glitches and characters behaving strangely.

The programmers listen to feedback about bugs and then debug the programs. They update it to a new version, usually with a number such as version 1.2.

The 18 million dollar bug

The fate of the Mariner 1 spacecraft back in 1962 is an example of a tiny bug causing a huge problem!

The unmanned spacecraft was programmed to visit the planet Venus nearly 200 million miles away and send back information to scientists here on Earth.

Unfortunately, someone had typed the wrong symbol into the program code somewhere and hadn't spotted the mistake.

Mariner 1 went crashing off course and had to be destroyed just 290 seconds after launch to prevent it crashing back to Earth.

This turned out to be an 18 million dollar bug. But was it a syntax bug or a logic bug?

Back to top

Watch: Debugging

Learn more about debugging with this video from 成人快手 Teach.

Back to top

Activities

Back to top

Computing - Dance Mat Typing. game

Build and test your computing skills with different levels of touch type challenges

Computing - Dance Mat Typing
Back to top

More on Computer science

Find out more by working through a topic