Garbage Collector


The little space of a writer, tinkerer, and a coffee addict

The Rubber Duck Debugging method

The Rubber Duck Debugging method
My own rubber duck, with its security racing helmet. Licensed under CC-BY-SA 4.0.

As far as I remember my career beginnings, I’ve almost always seen someone with a rubber duck on their desk. Some former colleagues had an entire collection populating their workstation, but I must admit I’ve never understood why the rubber duck had that kind of popularity. Even I have one, a goodies obtained during a training session. I’ve 3D-printed the helmet for the fun.

So, after some quick search, I’ve discovered an idea which I was already using without knowing it : the Rubber Duck Debugging method. This method is named after a story in the book The Pragmatic Programmer in which the programmer explains its problem to a rubber duck and finally solve it just by explaining it.

In fact, despite not being myself a programmer, I’m still writing scripts and automation procedures that can need debugging and analysis too. Like many people, I’ve experienced several times the situation in which you have a blocking problem, you don’t understand why, and by just explaining to a colleague you discover the solution (or just by writing the question on Stack Overflow). This behavior has been several time experienced and proved to be very effective. By just describing your code, line by line, what it’s doing, what you want it to do, you can find to solution of many problems.

This way works with inanimate objects too. Traditionally, the rubber duck became a usual figure of an object you speak to and have your “Eureka !” moment. But the object can be anything… Your dog, your cat, your teddy bear, your chair, a penguin, anything you want. The important thing it to verbally speak and explain your problem to your duck or dog. You explain your goal, you explain line by line what’s you’re doing, and typically you’ll find out what’s wrong.

It looks fun, but there are psychological explanations to this. Usually, we think faster than we talk. When you’re writing your code, you do it just like when you’re writing any other texts : you think about the idea and the words come naturally. But, when you are talking, you will want to be more precise and careful to what you say because you want to be understood. In this case, you think slower to match your verbal wording.

In this process, there is a second important item : the Rubber duck does not know as much as you about your problem. So you will have to explain it. Apparently, this mechanism would be based on Piaget’s theory of cognitive development, especially in the “concrete operations” stage where a child learns that people might have different perspectives and understand other than one’s own.

This is what makes the Rubber duck debugging method effective : by telling your duck the problem, you put yourself in the place of the person that has no knowledge of your work. Because of that, you force yourself to be clear and careful in your explanation to ensure the Duck understand it. The result of this exercice is that you focus your attention to things that was too obvious or considered as granted in your mind, and unwillingly ignored. Then, the logic takes the place and suddenly… “Eureka !”.

So, I’m glad to discovered something I was already using without knowing it. I strongly recommend this practice because it’s a real problem solver, and also a fun way too. So, every time you are stuck, invoke your duck and the magic of the human psychology will do the rest.


πŸ“š Read my latest book

Follow me on Mastodon

🏷️ All Tags πŸ“„ All Posts πŸ—Ί Sitemap RSS Feed