Debugging
Debugging is the process of finding out why a program isn't doing what you expected, and fixing it. The term comes from an actual moth found stuck in an early computer's hardware in 1947 — "debugging" meant literally removing it.
A practical approach:
- Reproduce the problem reliably — know exactly how to make it happen again.
- Narrow it down — print out or inspect values at different points until you find where reality stops matching your expectation.
- Fix the smallest thing that explains the wrong behavior, then re-test.
Almost no developer writes code that works perfectly on the first try — debugging isn't a sign of failure, it's most of the actual job.