Skip to content
BENIBIX Learn

Debugging

Development🧩 Programming ConceptsErrors

Also known as Debug

The work of finding out why code goes wrong, then fixing it.

Think of it like

Think of it like being a detective. You gather clues, guess who did it, and test your guess.

Example

Lucy's total is off by one cent. She prints the value after each step and finds a float rounding error on line 14.

Why it matters

Every developer spends a large share of their time debugging. Doing it with a method saves hours.

Definition

Debugging is the work of finding and fixing bugs. First you make the bug happen again on purpose. Then you narrow down where it lives, by reading messages, printing values or stepping through the code. Once you find the cause, you fix it and check the fix. Good debugging is calm and step by step, not random changes.

Example code

python
total = 0
for price in [0.1, 0.2]:
    total = total + price
    print("total so far:", total)   # a quick debug line
Printing the value at each step shows where it first goes wrong.

Common mistake

Changing things at random until it works. You may hide the bug, and you learn nothing about the cause.

Key takeaways

  1. 1
    Make it happen again. A bug you can repeat is half fixed.
  2. 2
    Narrow it down. Cut the search area in half each step.
  3. 3
    Check the fix. Run the failing case again after.

Learn it properly