Rubber duck debugging

From HandWiki
Short description: Code debugging method
A rubber duck in use by a developer to aid debugging

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.

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]

On 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

References

  1. 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.
  2. Debugging, Rubber Duck. "Rubber Duck Debugging". https://rubberduckdebugging.com/. 
  3. 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. 
  4. 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 .
  5. 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/. 
  6. 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. 
  7. Attwood, Jeff (2012). "Rubber Duck Problem Solving". https://blog.codinghorror.com/rubber-duck-problem-solving/. 
  8. Malan, David (2020). "Rubber Duck Debugging in CS50 IDE". https://cs50.noticeable.news/posts/rubber-duck-debugging-in-cs-50-ide. 
  9. Purushothaman, Praveen Kumar (31 March 2018). "Quack Overflow - Stack Overflow's take on April Fool!". https://blog.praveen.science/quack-overflow-stack-overflows-take-on-april-fool. 
  10. "Stack Exchange has been taken over by a rubber duck!". 31 March 2018. https://meta.stackexchange.com/a/308578.