Debugging and testing — Computing, 14–17 years
How programmers find out what went wrong, then gather evidence that a program works in more than one lucky case.
Idea
Debugging is the investigation of a program that behaves differently from what was intended. Testing is deliberately trying inputs and checking the results against expectations. Together they turn “it seems broken” into a specific, repeatable problem that can be fixed and checked again.
Why it matters
Programs are written by people, and real inputs include surprises: empty fields, huge values and unusual combinations. A program that works once may still fail tomorrow. Testing grew from the need to find faults before users do, while debugging provides a disciplined way to trace a fault back to its cause.
Worked example
A function should return the average of 4 and 6, but returns 10. First, repeat the test and write the expected result: (4+6)/2=5. Next, inspect the code and notice it adds but never divides by 2. Add that operation, run the same test to get 5, then try 0 and 10 to check more than one case.
Common trap
A reasonable mistake is to change several lines at once because that feels faster. If the result improves, however, you may not know which change helped; if it gets worse, you have more possibilities to inspect. Change one likely cause, run a small test, and keep the evidence from each step.
Where it appears
Before an online shop accepts a payment, its software is tested with valid cards, declined cards and interrupted connections. Phone apps are checked on different screen sizes and operating systems. Safety-critical systems use especially careful tests because a hidden fault in a train signal or medical device can affect real people.
Keep exploring
Other languages
Loading MyLeoNes™…