Skip to content
BENIBIX Learn

Rubber Duck Debugging

Development🛠️ Editors & ToolsCode Quality Tools

Also known as Rubber Ducking, Rubber Duck Method, Duck Debugging

You say your code out loud, line by line. Then you spot the mistake.

Think of it like

It is like telling a friend how a game works. Halfway through, you spot the rule you got wrong.

Example

Mia is stuck on a loop that skips the last item. She explains it to the duck on her desk. When she says it stops before the length minus one, she hears the mistake.

Why it matters

It finds many bugs in minutes, with no tool and no need to wait for a colleague.

Definition

Rubber duck debugging is finding a bug by explaining your code out loud, line by line, to something that cannot answer. Many people keep a toy rubber duck on the desk for this. To explain each line, you must say what it really does, not what you hope it does. The gap between the two is often the bug. It works because talking slows you down, not because the duck helps.
You say each line out loud to the duck, and the line that skips one stands out.

Common mistake

Skimming the lines you trust. The bug is often in the part you were sure was fine, so say every line.

Key takeaways

  1. 1
    Out loud. Speaking slows you down.
  2. 2
    Every line. Skip nothing, even the easy parts.
  3. 3
    Any listener. A duck, a pet or a note.

Learn it properly