Rubber duck debugging refers to debugging your code with the aid of a rubber duck. You explain each step of your code to the duck until you notice the problem that has been causing the unexpected behaviour. Rubber duck debugging was first coined in the book, The Pragmatic Programmer, by Andrew Hunt and David Thomas.
Are you into rubber duck debugging?
Top comments (30)
I often ask my colleagues to be the Rubber Duck (yes that's strange to say that), it's easier to talk to humans for debugging even if they don't have the full context or technical knowlegde:
And it's working most of the time!
My team have 3 sessions a week in the diary for this kind of debugging, of course it also happens at other times too!
This is an excellent idea and I believe it is the best one because then you get input :D
I am the duck.
You are one with the duck.
I am one with a different duck...
Here I am, explaining code to myself.
Hahaha! That is one damn good GIF.
Haha! 😂 Teammate duck! 🪞
Yes, there's a fairly simple explanation for it, too - if you're only thinking (not speaking), you process about 1200 words / minute.... but if you talk, you slow down significantly (even fast talkers sustain at around 300).
The reason that the duck works is because when you slow down to explain it, you actually get a chance to think harder about what you're saying, and the answer usually bubbles right up!
I prefer penguin debugging
I know it's not a competition but for fun I'll raise you 300% clout and a tropical beverage:
OH, YOU WANNA COMPETE? (I hope not, I don't have too many photos of Godofredo)
I have many more penguins but I hesitate to produce them:
That is one awesome penguin as well 😊
Aw, cute penguin. Cool glasses 😎
I usually try to explain the issue in my head to someone else, before actually explaining it to them. 90% of the time it solves the issue before bothering them
I guess that is a form of rubber duck debugging?
I truly believe it is! I am yet to use a rubber duck myself.
Yes, I have a large rubber duck in my office for this reason. Sometimes my wife nods along and acts as the duck instead.
When I was in college I would use our pet bulldogs, but they were more interested in my snacks haha.
It's a great technique.
You often find solution by stepping out, and explaining the problem out loud.
It happens when I explain my current issue/doubts about an implementation or refactoring. Most the time, they will give you feedbacks about your issue, but sometimes you will be the one suggesting the solution. The discussion generally ends by a "thanks for being my rubber duck today"
My wife knows and likes this concept, so she bought me a real one this last year:
Here is a Wikipedia article if you want to go further
In software engineering, rubber duck debugging 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. 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. When humans are involved, it is known as confessional programming.
You are absolutely correct! Whenever we encounter a problem which we struggle with, it can more often than not be most helpful to get out of our heads and say it out loud. Strange how that works but it does!
PS! Awesome pictures :)
Here is the deal. Imaginary partner syndrome. Line by line describe your code to find mistake.When i am coding, sometimes talk to a bad character like Davy Jones (a cruel sly pirate) is much more efficient than the rubber duck. Rubber duck is adorable funny pal but the customers, no sir!
I've been the duck, almost always. 😂 But reading this post gave me this idea I would like to test out, could we make use of GPT and improve rubber duck debugging?
Here's a prototype for Rubber Ducker @ coze.com/s/ZmFquWNtX/
have to admit that i would have to "rubber duck" more often. What helps me most is to physically take a step back from the problem, two to three hours, and then slowly roll up the problem again ... it often helps me to build up distance, to talk to other people about something completely different, to move around and suddenly an approach comes over me. In fact, i am then completely back to the task at hand and motivated to find a solution