Rubberducking

Published

2023-07-31

Rubberducking

“Rubberducking”? What on Earth is “rubberducking”? Don’t laugh: rubberducking is one of the most powerful debugging tools in the known universe! Many programmers keep a little rubber duck handy on their desk, in case of debugging emergencies.

Here’s how it works. If you get stuck, and cannot solve a particular problem or cannot fix a pesky bug you talk to the duck. Now, rubber ducks aren’t terribly sophisticated, so you have to explain things to them in the simplest possible terms. Explain your problem to the duck using as little computer jargon as you can. Talk to your duck as if it were an intelligent five-year-old. You’d be amazed at how many problems can be solved this way!

Why does it work?

First, by talking to your duck, you step outside your code for a while. You’re talking about your code without having to type at the keyboard, and without getting bogged down in the details of syntax. You’re talking about what you think your code should be doing.

Second, your duck will never judge you. It will remain silent while you do your best to explain. Ducks are amazing listeners!

It’s very often the case that while you’re explaining your troubles to the duck, or describing what you think your code should be doing, that you reach a moment of realization. By talking through the problem you arrive at a solution or you recognize where you went wrong.

What if I don’t have a rubber duck?

That’s OK. Many other things can stand in for a duck if need be. Do you have a stuffed animal? a figurine of any kind? a photograph of a friend? a roommate with noise-cancelling headphones? Any of these can be substituted for a duck if need be.

The important thing is that you take your hands off the keyboard, and maybe even look away from your code, and describe your problem in simple terms.

Trust the process! It works!

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).