Rubber duck debugging
Slang informal
Finding a mistake in your code, or your thinking, by explaining the problem step by step out loud, even to a toy duck.
Meaning & usage
Rubber duck debugging is a problem-solving trick used by programmers. When stuck, you explain your code line by line to a listener who knows nothing about it, traditionally a rubber duck on the desk. Putting each step into words often makes the error obvious before you finish.
The term is used both literally and loosely. People say they need to “rubber duck” a problem with a colleague, meaning the colleague only has to listen. The method works for writing, maths and planning too.
Examples
- I found the bug halfway through rubber duck debugging it with my cat.
- Can I rubber duck this with you? You don't have to say anything.
- There's an actual rubber duck on every desk in our office for rubber duck debugging.
Origin & history
The name comes from the 1999 book The Pragmatic Programmer by Andrew Hunt and David Thomas. It tells of a programmer who carried a rubber duck and debugged code by explaining it to the duck, line by line.
The idea itself is much older: teachers and programmers had long noticed that explaining a problem to someone else helps you solve it. The memorable image of the duck gave the habit a name, and it spread widely among software developers in the 2000s.
Notable people & uses
Andrew Hunt and David Thomas, The Pragmatic Programmer (1999).
Related terms
Sources
- Andrew Hunt and David Thomas. The Pragmatic Programmer. Addison-Wesley, 1999.