Rubber duck debugging

Rubber duck debugging (or rubberducking) is a debugging technique in software engineering. A programmer explains their code, step by step, in natural language—either aloud or in writing—to reveal mistakes and misunderstandings.
The name is a reference to a story in the book The Pragmatic Programmer. It tells a story of a developer who carried a rubber duck and explained their code to it line by line.[1] Variations of the practice use other objects or even pets; teddy bears are especially common.[2][3]
Approach
Programmers often discover solutions while explaining a problem to someone else, even to people with no programming knowledge. Describing the code, and comparing to what it actually does, exposes inconsistencies.[4] Explaining a subject also forces the programmer to look at it from new perspectives and can provide a deeper understanding.[5]
The programmer explaining their solution to an inanimate object (such as a rubber duck) has the advantage of not requiring another human, but also works better than thinking aloud without an audience.[6] This approach has been taught in computer science and software engineering courses.[7][8]
In popular culture
On 1 April 2018, Stack Exchange launched an April Fools' Day joke called Quack Overflow. A rubber duck avatar appeared in the bottom right corner of the screen, listened to user problems, and pretended to type solutions, only to respond with a simple "quack" sound. It referenced rubber ducking as a powerful method for solving problems.[9]
See also
- Code review
- Pair programming
- Socratic method
- Desk checking
- Duck test
- Duck typing
- Software walkthrough
- Eureka effect § The Aha! effect and scientific discovery
- Think aloud protocol
- Pointing and calling
- Rogerian method
- Worry dolls
- Learning by teaching
- Body doubling
References
- ↑ Hunt, Andrew; Thomas, David (1999). The Pragmatic Programmer: From Journeyman to Master. Addison Wesley. ISBN 978-0201616224. https://archive.org/details/isbn_9780201616224. p. 95, footnote.
- ↑ Debugging, Rubber Duck. "Rubber Duck Debugging". https://rubberduckdebugging.com/.
- ↑ Boswell, Dustin; Foucher, Trevor (2011). The Art of Readable Code: Simple and Practical Techiques for Writing Better Code. O'Reilly and Associates. pp. 137. ISBN 978-0596802295.
- ↑ Baker, SJ, The Contribution of the Cardboard Cutout Dog to Software Reliability and Maintainability, http://www.sjbaker.org/humor/cardboard_dog.html, retrieved 9 February 2011.
- ↑ Hayes, David (25 June 2014). "The Psychology Underlying the Power of Rubber Duck Debugging". http://pressupinc.com/blog/2014/06/psychology-underlying-power-rubber-duck-debugging/.
- ↑ Byrd, Nick; Joseph, Brianna; Gongora, Gabriela; Sirota, Miroslav (2023). "Tell Us What You Really Think: A Think Aloud Protocol Analysis of the Verbal Cognitive Reflection Test". Journal of Intelligence 11 (4): 76. doi:10.3390/jintelligence11040076. PMID 37103261.
- ↑ Attwood, Jeff (2012). "Rubber Duck Problem Solving". https://blog.codinghorror.com/rubber-duck-problem-solving/.
- ↑ Malan, David (2020). "Rubber Duck Debugging in CS50 IDE". https://cs50.noticeable.news/posts/rubber-duck-debugging-in-cs-50-ide.
- ↑ "Stack Exchange has been taken over by a rubber duck!". 31 March 2018. https://meta.stackexchange.com/a/308578.
External links
