Rubber Ducking

ThePragmaticProgrammer's CardboardProgrammer.

See ThePragmaticProgrammer, p. 95. (The footnote (7) explains the origins of the term)

Place a rubber duck on your monitor and describe your problems to it. There's something magical about stating your problems aloud that makes the solution more clear.

DanielDennett has a good theory for why this helps. He puts forth the view (in ConsciousnessExplained?) that consciousness developed as a way to internalize talking to oneself. Speaking words triggers parts of the brain involved in moving the diaphragm, tongue, lips, vocal cords, etc.. Hearing words triggers parts of the brain connected to the ears. Speaking aloud can be a bad survival strategy, especially when you're thinking about the chief's wife, so we developed consciousness as an internal monologue. It works, but it doesn't exercise as many areas of the brain as speaking and hearing your own words. There's no way to test this theory, but it makes sense to me. See ThinkingOutLoud and SelfTalk for related explorations.


You can also write an email to a mailing list or newsgroup. While you will not have the acoustic feedback in this case, at least it forces you to bring your thoughts into order. So in 90% you will not need to send the email because you've already found the solution. In the remaining 10% you can just send your posting.


Think of the duck as a QwertySyndrome for the mind. It was claimed that forcing the stream of text through the mangled organization of the keyboard slowed the typist enough to prevent the mechanical typewriter from jamming. Likewise, by forcing thoughts through the slow engine of the mouth, one can clearly express a single train of thoughts. The mind is then more capable of using the thoughts to solve the problem.

I have always held this belief, more or less consciously. When I was small, people would always tell me to stop talking to myself. Later, I stopped having audible conversations (one more acquired trauma). Maybe I'm losing something in that, but I still do seem to get the slowdown effect. Without that, my mind races too fast and in too many directions. It feels like I had about three layers of thought of which one would occasionally jump to the top and one would occasionally die and be replaced. Steering that was difficult without a CardboardAnalyst.


The PragmaticProgrammers book doesn't say it this way, but at least one Wikizen has held this theory for a while:
Once a problem is described in sufficient detail, its solution is obvious. Kent(12:11) ;)

Some examples: (Counter-examples welcome)

There won't be any. It's a tautology. The problem is that word "sufficient". If the solution isn't obvious, then the description isn't detailed enough. Fermat's last theorem was pretty sufficiently detailed. The solution is hard to consider obvious. That's math. Programming is special in that the tasks we undertake are simple in principle, but difficult in practice. In contrast, math is unsolvable in principle, but merely difficult in practice.

But the (an?) important thing is to be specific. "Prove Fermat's Last Theorem" is an insufficiently "tight" problem. Once you work out what it is that you need to do right now then, even in maths, it's often obvious (to someone who's mathematically inclined, anyway.) I know this is true, since I just added a major piece to my current proof by the discussion below:

ME: I need to leave a message on Mum's answerphone. She's away, and she always does my CardboardCutout?ing for my proofs.

FRIEND: Well, it doesn't sound like CardboardCutout?ing is particularly difficult. Explain to me instead.

ME: ....(technical maths stuff)...

FRIEND: Uh-huh.

ME: ... (you get the picture) ... Oh, and now I see what it is I need to prove. And that's easy.''


On the other hand, Fermat's last theorem may be entirely obvious from inspection if you've got a good grasp of the problem space, just like the four color theorem is. Play with lines and coloring spaces on a plane for a while and it becomes entirely clear that no matter how you arrange stuff you're never going to need a fifth color. Play with a**n + b**n - c**n with a handful of small numbers and it becomes entirely clear that they aren't going to line up, and there's no reason to expect that for some magical four whole numbers they might. The problem is that linear proof language didn't grown out to meet the requirements of proving these assertions with brief statements that don't have an odious "by inspection" step in them. So, adding a whole new language of color choice option counting or getting squares by summing other squares may be required as part of the sufficiency of the detail. Also, toy problems of technically difficult proofs such as these are rarely actually blockers for real problems, and we have no idea if Fermat would have asserted the modularity of rational elliptic curves and such in so many words had he the time or what: the "real problem" may often be, why does the lack of formal approval for such an obvious-by-inspection assertion block one's happiness?


Discussion:

  Rubber Ducky, you're the one.
  You make bathtime lots of fun.
  Rubber Ducky, I'm awfully fond of you.
    (Ooo, bobo beo)
  Rubber Ducky, joy of joys!
  When I squeeze you, you make noise!
  Rubber Ducky, I'm awfully fond of you.

Every day when I, make my way to the tubby, I find a, liddle fellah who's, Cute and yellah and chuu-by (Rub-a-dub dubby)

Rubber Ducky you're so fine, And I'm lucky that you're mine, Rubber Ducky, I'm awfully fond of, Rubber Ducky, I'd like a whole pond of- Rubber Ducky, I'm awfully fond of you.
Could also be rubber duckling. This is meant to be a verb [a gerund, actually], though - when you have problems, try rubber ducking. I don't think ducking as a noun exists anywhere. [It exists as a gerund (which is a noun), because "duck" exists as a verb. In this context, however, "duck" the verb is a verbalization of "duck" the noun; such verbalization is always allowed (though not necessarily meaningful) in English.]


Sometimes, my students start explaining their problems to me, and realize the solution before I even say anything. One student decided it would be easier just to have a "Dave doll" at hand. -- djbr
I really would love to do that, but in combination with an open concept office, I'm worried it would be a CareerLimitingMove. Argh.

Forgive me for making you over-explain this, but are you saying: "If they realize that they can solve their own problems by talking them through out loud, they won't need me"? (Or are you saying something else entirely?)

Talking aloud to yourself is frowned upon in some circles. Yeah, but talking to a duck should be fine. ;-)

My rule is that it's OK to talk to yourself, as long as you don't use Funny Voices. -- TomVanVleck

On the other hand, one could silently explain one's problems to the duck. People might assume you're spacing out, as you stare at the duck, but in reality, you're mentally explaining the problem to the duck. That doesn't perform the aforementioned brain stimulation from making actual sound and listening.

That doesn't perform the aforementioned brain stimulation from making actual sound and listening. Actually, it might to at least some extent; if you make sure to think of it as *talking* to the duck rather than just "explaining" to the duck, you will almost certainly be subvocalizing. No, you won't be *hearing* yourself; that benefit is lost. But it's very likely to trigger at least some of the extra stimulation of your brain, since you're going to be actually making jaw and mouth movements when subvocalizing.


Is this another form of AskTheCode?
I've experienced this too, in the form Dave had above; we nicknamed it 'confessional programming'. Conversations go like this;

Person 1: "My code doesn't work! I've got all these objects in an ordered list, and I assume they can all... oh. Ah, yeah. I see the problem. Thanks for your help."

Person 2: "..."

Cool! How do you pronounce ellipses? I've seen characters in RPGs do it, and never understood what noise they were supposed to be making. (Answer: It sounds just like a tree falling in the woods with no one around to hear it.)

An even more intriguing question is: how are ellipses intoned as a question? As in "... ...?" *shudders* Is it like pronouncing the TetraGrammaton? -- JoeOsborn (Possible answer: Consider Tim Allen's trademark "Uhhrroo?" questioning noises from the Home Improvement television show.)

The ellipsis has always been my way of signifying a blink. I hardly ever blink, so making it obvious adds great effect when talking with people who actually know what I mean when I write ... out of nowhere. -- RobRix

I've always used it to signify a sort of half-utterance (or even nil-utterance) - you open your mouth to speak but there's just nothing to say. A "...?" might be an open-mouth confused expression, and a "...!" might have a finger raised in a silent "Aha!" -- DanielChurch
"Jeffrey Friedl, author of MasteringRegularExpressions, has a toy named Tubby which he apparently uses to bounce ideas off. It seems to me to be a kind of familiar, as in witchcraft, I don't know if it is categorized anywhere else."

Sounds to me as if you talked to the cat, then this would avoid the career-limiting move and it might make you a wizard programmer. :) -- Ian H

I find that trying to talk to my cats about anything is frustrating. As soon as they notice they're getting some attention, they'll come and brush against me and try to lure me to the kitchen where all the food is.

"For purposes of full disclosure, I have one of those bobble-headed dogs that you find in car windows on the top of my computer that serves the same function." -- SeanOleary

Is it worth having a list of questions to ask about the situation or get people in this situation to ask? I realize some questions may be fairly generic, some specific to the development environment. -- TurlochOTierney
You can even pair program with a rubber duck.

It would be perfect if you added a little voice chip that asked, "Did you write the test?"

As seen in American Beauty. In the morning, the duck should say You will implement the story today! and in the evening, You weak! You baby! :-)

See also TimoTheCodeMentorDog? at http://www.object-arts.com/oopsla/XP-BestFriend.htm.
Mine is a little troll doll with rainbow hair. It was given to my wife by a client of hers as a token of appreciation. She gave it to me one day to lighten things when I was in a rotten mood (I think ManagersAreEvil) and it became a fixture atop my monitor. We don't speak (I think co-workers would be freaked by a talking doll), but we commune.

I get looks when I smile at the doll, but better that than a distressed colleague babbling, "It talked!" -- GarryHamilton

The only good advice I ever got concerning wife / kids / job / finances was from Mr. Chips, my springer spaniel. -- BenTremblay
Sometimes writing a letter does the same thing, and people don't look at you funny for writing letters, even to imaginary friends.

That sounds like blogging. In fact, there is another saying that goes with this, "The best way to learn is to teach." When you ask your "students" the questions, you tend to see the holes in your plot. I suppose writing letters to yourself would keep you from falling into a hole. ;)
I've come across this general solution, but I've heard it expressed as, "Explain or describe the problem as if you were telling your mother about it. Then the solution becomes obvious."
Maybe ElizaDoctor or another ChatBot instead of a rubber duck is a good replacement: http://www-ai.ijs.si/eliza-cgi-bin/eliza_script This way it isn't a CareerLimitingMove anymore :-)
I have a small WinnieThePooh character on my desk - who as we know, is very wise: http://www.just-pooh.com/tao.html. -- JayBell

Or, we could just, you know, behave as if we weren't crazy people, and actually think in our heads.

That would be crazy!


This all seems to be in parallel with something I do for any project, be it programming, art, writing, or something else altogether; ThinkingWithaPen?. I do a lot of coding late at night (bad insomnia; I sleep a lot during the day), so I don't have anybody to talk with and noise would disturb the parents... so I draw everything. I'm an artist first, programmer second, so this is more tuned to how my mind works, but perhaps it would help others. -- RobRix

See LogBook. I wonder if this is what cartoonists do. Draw the problems of nagging thoughts they have into (possibly silent) dialogue between characters in the strips?


Generally, I pair program with a text file (instead of a rubber duck). There I can have novel discussions with my alter-ego, who generally has something wise to say. And indeed, sometimes just explaining the problem or issue enlightens me to the space of possible solutions. -- cfitch


I have a granite cobblestone on my desk. I usually say it is a computer which was turned into stone one night. In a way it was - just a few days before we got our security improved at the office, thieves broke a window with the stone and ran away with two old, lousy PCs, on which I had *just* installed Linux the day before, thus completely bare. Hardly a loss. Anyway, I use it for many purposes, although I haven't talked to it (yet). I think I have told people more than once to talk to the stone instead of me, though. It is also good for waving about, either when my office mates tease me (being a developer with a fraction of sysadmin responsibility - and sysadmin background - among "ordinary" but proud developers), or when some problem turns out to be particularly nasty, or caused by someone else's stupidity. The weight of it feels quite good in those situations. It is also quite handy as a paperweight when I open my window on windy summer days. I haven't beaten anyone with it - yet. As for solitary chatting and pair programming, I suppose two xterms with talk running in each could be useful. -- LasseHp


The version of this story I'm familiar with involved not Rubber Duckys, but Teddy Bears. The only citation I can find for this at the moment is here:

http://www.progsoc.uts.edu.au/lists/slug/2001/May/msg00595.html

Basically, there was a university computer programming lab [MIT?] where in one corner sat a perfectly ordinary teddy bear. If you were a student working in this lab, and you were stuck on something, the rule was that you had to explain your problem to the teddy bear first, then go back to your work and try to apply whatever wisdom the bear imparted upon you. If you were still stuck at this point, then and only then were you allowed to ask for the help of the lab's tutor.

If someone comes up to you seeking help with a problem, and during the course of explaining the problem to you they figure it out for themselves, you are being that person's teddy bear. -- cdevers


Our team always called that "german shepherding". As in, "Hey, Nate, can you german shepherd for me for a minute?" I still periodically ask my (non-techie) housemates to german shepherd for me, and they very obligingly provide me with the answers to the most difficult technical questions. It's really quite magical. -- MickeyPhoenix


See MultiplePersonalityDevelopment


I love this suggestion; particularly the irreverent use of a toy to force the mind out of work time. -- MikeZillion?


Back in college, I used to study by going to an empty classroom, putting a stuffed bear in a chair, and lecturing to him. When he was particularly dense, I threw erasers at him.


Along similar lines (see 'being a person's teddy bear' above), a coworker and I would often IM one another with a problem. A few minutes later, with the askee having not really contributed anything, the asker would have figured out what they needed to. We would joke that the askee could have just answered every question with "moo" and gotten the same effect.


Hardware, it would seem, responds in the same way. After hours of struggling with some recalcitrant hardware I decide to call over the engineer or sysadmin. As I explain the problem it either 1) starts working or 2) the missing detail becomes apparent and the engineer wanders off muttering about 'damn developers' and how is he supposed to enter 3 minutes into his timesheet. Not that I am comparing systems with plushies, oh no. That would be more than my life is worth...


Walking to and from work is good for this: only the cats and the birds can hear you (though this might not be a good thing in the case of the ducks.

I find that I do this while typing out a question on FreeNode IRC. I start typing out a question, and in the process of describing the issue and making sure I didn't do anything stupid, I find that I did do something stupid, and need to erase my perfect question. Bonus: if i do not come up with a solution while researching the problem, I have an exceptional question to pose to a bunch of people.
I just type a nice big comment in the source file, documenting what must be tackled in the next phase of coding. Sometimes I will even present different options for how to proceed. One advantage of this is that I can stop programming (to answer the doorbell) without losing my thought process. Also someone else could pick up from where I left off. The disadvantage: if I leave the comments in the file, it can look pretty messy! It's best to tidy up afterwards. -pnc
Reading this page, I have determined that my first pay check as a tenured employee is going to buying an anime figure (well, actually, a Touhou Project figure). "Hey Komachi, could you please help me out with this code? I can't figure out why it's segfaulting...".
See also AhaMoment

EditText of this page (last edited September 22, 2014) or FindPage with title or text search