# Rubber Duck Debugging

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

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Rubber Ducking, Rubber Duck Method, Duck Debugging

## Think of it like

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

## 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.

## 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.

## Common mistake

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

## Three principles

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

## Related terms

- [Debugging](https://learn.benibix.com/term/development/debugging)
- [Print Debugging](https://learn.benibix.com/term/development/print-debugging)
- [Pair Programming](https://learn.benibix.com/term/development/pair-programming)
- [Off-by-One Error](https://learn.benibix.com/term/development/off-by-one-error)
- [Bug](https://learn.benibix.com/term/development/bug)
- [Debugger](https://learn.benibix.com/term/development/debugger)

## Taught in

- [Debuggers and Breakpoints](https://learn.benibix.com/learn/development-tools/debuggers-and-breakpoints): Coding Tools, 5/13

![Two panels on finding a bug without a debugger. Print debugging: four lines of code, two of them print lines that show the price and the total. Run it, and the output reads DEBUG price: 0, marked as the first wrong value, then DEBUG total: 0. The print lines come out again afterwards. Rubber duck debugging: three steps of a loop said out loud. Start at the first item, ok. Add each price, ok. Stop before length minus 1, marked skips one. A duck sits below and only listens.](https://learn.benibix.com/diagrams/left1-debugging.svg)

---

Source: https://learn.benibix.com/term/development/rubber-duck-debugging
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
