Debugging: finding and fixing errors — Computing, 7–10 years
Debugging is the careful process of finding why a program does not behave as planned and changing it. You will learn to use evidence from tests instead of guessing or starting again blindly.
What is debugging?
A bug is a mistake in a program, and debugging is the search for its cause and repair. You compare what the program did with what you expected. Then you change one part, test again and keep evidence about whether the fix worked.
Why do we debug?
Programs are written by people, and people can misunderstand a problem, miss a detail or make a typing mistake. Debugging solves the problem of turning an unexpected result into a useful clue. It makes programs more reliable instead of relying on luck.
Example: a wrong total
A shopping program should add 3 euros and 2 euros, but shows 32 euros. First, repeat the test with the same numbers. Next, inspect the operation: the program joined the digits instead of adding them. Replace joining with addition, test again and check that the answer is 5 euros.
The trap: changing everything
When a program fails, it is tempting to change many lines at once or blame the whole idea. This is reasonable when the error feels mysterious, but it removes your clues. Change one small part, test it, and record what happened so you can narrow the search.
Where does it appear?
Debugging is used in games, websites, robots, traffic systems and apps. A team may test a new button, notice that it opens the wrong screen, find the faulty instruction and release a correction. The same habit helps when checking a spreadsheet or a set of instructions.
Keep exploring
Other languages
Loading MyLeoNes™…