MyLeoNes™

Debugging: finding and fixing errors — Computing, 11–13 years

Debugging is a method for discovering why a program behaves differently from what you intended.

Debugging is detective work

A bug is a mistake in a program, and debugging is the careful search for its cause. You observe what happened, form a small guess, test it, and use the result to narrow the search instead of changing random lines.

Why guessing fails

Programs can fail because of a typing error, a wrong assumption, or data arriving in an unexpected form. Debugging grew from the need to make large, complicated systems reliable: a repeatable investigation is safer than hoping a change fixes everything.

Finding a wrong total

A shopping program should add 3 euros and 4 euros, but displays 34. First repeat the test and note the exact input. Then inspect the operation: the program joined the two pieces of text instead of adding numbers. Converting them to numbers gives 7.

Changing too much

People often rewrite several parts at once because the whole program feels suspicious. That is a reasonable reaction when a problem is frustrating, but it removes evidence: if the result changes, you no longer know which change mattered. Alter one small thing and test again.

Reliable systems

Debugging is used in apps, games, robots and scientific software. It also appears in everyday problem-solving: reproduce a fault, change one likely cause, and check the result. The same habit helps find a loose cable as well as a faulty instruction.

Keep exploring

Other languages

Loading MyLeoNes™…