rubber duck debugging

{{short description|Code debugging method}}

{{Use dmy dates|date=November 2019}}

File:Rubber duck assisting with debugging.jpg in use by a developer to aid debugging]]

In software engineering, rubber duck debugging (or rubberducking) is a method of debugging code by articulating a problem in spoken or written natural language. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line by line, to the duck.{{Cite book | isbn = 978-0201616224 | url = https://archive.org/details/isbn_9780201616224 | title = The Pragmatic Programmer: From Journeyman to Master | publisher = Addison Wesley | url-access = registration |first1=Andrew |last1=Hunt|first2= David|last2=Thomas|year=1999}} p. 95, footnote. Many other terms exist for this technique, often involving different (usually) inanimate objects, or pets such as a dog or a cat. Teddy bears are also widely used.{{Cite web |last=Debugging |first=Rubber Duck |title=Rubber Duck Debugging |url=https://rubberduckdebugging.com/ |access-date=2023-09-14 |website=rubberduckdebugging.com |archive-date=12 November 2020 |archive-url=https://web.archive.org/web/20201112022638/http://rubberduckdebugging.com/ |url-status=live }}

Approach

Many programmers have had the experience of explaining a problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the process of explaining the problem. In describing what the code is supposed to do and observing what it actually does, any incongruity between these two becomes apparent.{{Citation | url = http://www.sjbaker.org/humor/cardboard_dog.html | title = The Contribution of the Cardboard Cutout Dog to Software Reliability and Maintainability | last = Baker | first = SJ | access-date = 9 February 2011 | archive-date = 5 October 2013 | archive-url = https://web.archive.org/web/20131005123545/http://www.sjbaker.org/humor/cardboard_dog.html | url-status = live }}. More generally, teaching a subject forces its evaluation from different perspectives and can provide a deeper understanding.{{cite web|last1=Hayes|first1=David|title=The Psychology Underlying the Power of Rubber Duck Debugging|url=http://pressupinc.com/blog/2014/06/psychology-underlying-power-rubber-duck-debugging/|website=Press Up via Internet Archive|access-date=2021-09-10|date=25 June 2014|archive-url=https://web.archive.org/web/20140709011039/http://pressupinc.com/blog/2014/06/psychology-underlying-power-rubber-duck-debugging/|archive-date=9 July 2014}} By using an inanimate object, the programmer can try to accomplish this without having to interrupt anyone else, and with better results than have been observed from merely thinking aloud without an audience.{{cite journal |last1=Byrd |first1=Nick |last2=Joseph |first2=Brianna |last3=Gongora |first3=Gabriela |last4=Sirota |first4=Miroslav |title=Tell Us What You Really Think: A Think Aloud Protocol Analysis of the Verbal Cognitive Reflection Test |journal=Journal of Intelligence |date=2023 |volume=11 |issue=4 |page=76 |doi=10.3390/jintelligence11040076 |pmid=37103261 |pmc=10146599 |doi-access=free }} This approach has been taught in computer science and software engineering courses.{{cite web|url=https://blog.codinghorror.com/rubber-duck-problem-solving/|website=codinghorror.com|first=Jeff|last=Attwood|year=2012|authorlink=Jeff Atwood|title=Rubber Duck Problem Solving|access-date=16 November 2021|archive-date=12 February 2022|archive-url=https://web.archive.org/web/20220212144738/https://blog.codinghorror.com/rubber-duck-problem-solving/|url-status=live}}{{cite web|url=https://cs50.noticeable.news/posts/rubber-duck-debugging-in-cs-50-ide|website=noticeable.news|authorlink=David J. Malan|first=David|last=Malan|year=2020|title=Rubber Duck Debugging in CS50 IDE}}

See also

References

{{Reflist}}