
Rubber duck debugging (or rubberducking) is a debugging technique in software engineering, wherein a programmer explains their code, step by step, in natural language—either aloud or in writing—to reveal mistakes and misunderstandings.[1]
Definition
editThe name is a reference to an anecdote told in The Pragmatic Programmer by Andy Hunt and Dave Thomas. The book described rubber ducking as the method of explaining a problem to another party who do not "need to say a word; the simple act of explaining, step by step, what the code is supposed to do often causes the problem to leap off the screen and announce itself." The term referred to a research assistant Greg Pugh who carried around a rubber duck for this purpose. Variations of the practice use other objects or even pets; teddy bears are especially common.[2][3]
Approach
editProgrammers 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
editOn 1 April 2018, Stack Overflow 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.[9] It referenced rubber ducking as a powerful method for solving problems.[10]
See also
edit- 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
edit- ^ Kurata, Kandai; Tsuji, Airi; Fujinami, Kaori (2024). "uh-huh duck: Self-problem-solving support during programming through interaction with a doll duck". 2024 IEEE 13th Global Conference on Consumer Electronics (GCCE): 676–677. doi:10.1109/gcce62371.2024.10760316.
- ^ Debugging, Rubber Duck. "Rubber Duck Debugging". rubberduckdebugging.com. Archived from the original on 12 November 2020. Retrieved 14 September 2023.
- ^ Boswell, Dustin; Foucher, Trevor (2011). The Art of Readable Code: Simple and Practical Techiques for Writing Better Code. O'Reilly and Associates. p. 137. ISBN 978-0596802295.
- ^ Baker, SJ, The Contribution of the Cardboard Cutout Dog to Software Reliability and Maintainability, archived from the original on 5 October 2013, retrieved 9 February 2011.
- ^ Hayes, David (25 June 2014). "The Psychology Underlying the Power of Rubber Duck Debugging". Press Up via Internet Archive. Archived from the original on 9 July 2014. Retrieved 10 September 2021.
- ^ 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. PMC 10146599. PMID 37103261.
- ^ Attwood, Jeff (2012). "Rubber Duck Problem Solving". codinghorror.com. Archived from the original on 12 February 2022. Retrieved 16 November 2021.
- ^ Malan, David (2020). "Rubber Duck Debugging in CS50 IDE". noticeable.news.
- ^ Purushothaman, Praveen Kumar (31 March 2018). "Quack Overflow - Stack Overflow's take on April Fool!". Adventures (Blog). Retrieved 1 April 2018.
- ^ "Stack Exchange has been taken over by a rubber duck!". Meta Stack Exchange. 31 March 2018. Retrieved 1 April 2018.