Jump to content

Rubber duck debugging

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by MJKazin (talk | contribs) at 16:53, 2 July 2021 (Moved desk-checking to the "see also" section. It is not synonymous as it contradicts the entire premise of explaining the code to an external agent (instead, it uses a code printout - see https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv019.cgi?read=169827)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A rubber duck in use by a developer to aid code review

In software engineering, rubber duck debugging is a method of debugging code. 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.[1] Many other terms exist for this technique, often involving different (usually) inanimate objects, or pets such as a dog or a cat.

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.[2] More generally, teaching a subject forces its evaluation from different perspectives and can provide a deeper understanding.[3] By using an inanimate object, the programmer can try to accomplish this without having to interrupt anyone else.

File:StackExchange Rubber Duck Avatar April Fools 2018.png
The Stack Exchange rubber duck avatar featured on 1 April 2018

Insights are often found by simply describing the problem aloud.

— Duck, Quack Overflow

On 1 April 2018, Stack Exchange introduced a rubber duck avatar on their websites as a new feature called Quack Overflow. The duck appeared at the bottom right corner of the browser viewport, and attempted to help the visitor by listening to their problem and responding with a solution. However, the duck merely produced a quack sound after apparently thinking and typing. It referenced rubber ducking as a powerful method for solving problems.[4] Some confused visitors seeing the duck for the first time thought that a malware program had been installed in their computer before realizing it was an April Fools' Day joke.[5]

See also

References

  1. ^ The Pragmatic Programmer: From Journeyman to Master. Addison Wesley. ISBN 978-0201616224. p. 95, footnote.
  2. ^ Baker, SJ, The Contribution of the Cardboard Cutout Dog to Software Reliability and Maintainability.
  3. ^ Hayes, David (25 June 2014). "The Psychology Underlying the Power of Rubber Duck Debugging". Press Up. Retrieved 3 July 2015.
  4. ^ "Stack Exchange has been taken over by a rubber duck!". Meta Stack Exchange. 31 March 2018. Retrieved 1 April 2018.
  5. ^ Purushothaman, Praveen Kumar (31 March 2018). "Quack Overflow - Stack Overflow's take on April Fool!". Adventures (Blog). Retrieved 1 April 2018.