DEV Community

Are you Into Rubber Duck Debugging?

Anita Olsen on April 23, 2024

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 ...
Collapse
 
steeve profile image
Steeve • Edited

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:

  • First I'm the only one to talk, to make a quick recap of the situation
  • Then they ask (dum) questions :D

And it's working most of the time!

Collapse
 
miketalbot profile image
Mike Talbot ⭐

My team have 3 sessions a week in the diary for this kind of debugging, of course it also happens at other times too!

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

This is an excellent idea and I believe it is the best one because then you get input :D

Collapse
 
montyharper profile image
Monty Harper

I am the duck.

Collapse
 
michaeltharrington profile image
Michael Tharrington

You are one with the duck.

Howard the duck, a humanoid duck, from the movie by George Lucase, is waving his hand flatly in a strange way while looking ahead

Collapse
 
montyharper profile image
Monty Harper

I am one with a different duck...
Here I am, explaining code to myself.

daffy and daffy

Thread Thread
 
michaeltharrington profile image
Michael Tharrington

Hahaha! That is one damn good GIF.

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

Haha! 😂 Teammate duck! 🪞

Collapse
 
linkbenjamin profile image
Ben Link

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!

Collapse
 
phalkmin profile image
Paulo Henrique

I prefer penguin debugging

Image description

Collapse
 
cubiclesocial profile image
cubiclesocial

I know it's not a competition but for fun I'll raise you 300% clout and a tropical beverage:

Image description

Collapse
 
phalkmin profile image
Paulo Henrique

OH, YOU WANNA COMPETE? (I hope not, I don't have too many photos of Godofredo)

Image description

Thread Thread
 
cubiclesocial profile image
cubiclesocial

I have many more penguins but I hesitate to produce them:

Collapse
 
anitaolsen profile image
Anita Olsen

That is one awesome penguin as well 😊

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

Aw, cute penguin. Cool glasses 😎

Collapse
 
mrlinxed profile image
Mr. Linxed

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?

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

I truly believe it is! I am yet to use a rubber duck myself.

Collapse
 
marissab profile image
Marissa B

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.

Collapse
 
ccoveille profile image
Christophe Colombier • Edited

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:

Image description

Image description

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.

Collapse
 
anitaolsen profile image
Anita Olsen

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 :)

Collapse
 
gokayburuc profile image
gokayburuc.dev

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!
Davy-Jones

Collapse
 
salika_dave profile image
Salika Dave • Edited

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/

Collapse
 
cipivlad profile image
Cipi

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

Collapse
 
ranjancse profile image
Ranjan Dailata

The majority of the problems which I have solved is based on the inspiration of "Inception" movie. The more time diving into the code, living with it and spending time by in-depth analysis has lead to solving crucial problems.

Collapse
 
anitaolsen profile image
Anita Olsen

I love that film, it is so deep!

Collapse
 
ben profile image
Ben Halpern

It almost always works 😄

Collapse
 
kurealnum profile image
Oscar

Instead of talking to a rubber duck, I normally just talk to myself or the wall. I'm pretty sure that my family thinks I've finally lost it xD.

Collapse
 
anitaolsen profile image
Anita Olsen • Edited

Haha, I talk to myself as well xD

Collapse
 
qyrusai profile image
Qyrus

This is the best way to debug! Verbally processing with colleagues is fun, collaborative, and honestly makes debugging way less painful😂

Collapse
 
kerkg profile image
kerkg

no python made me go crazy and now Im the rubber duck