Debugging with a Rubber Duck
It happens to me all the time. I’ll be working through a particularly complex problem, and as soon as I decide to ask someone else for help, I find the solution while explaining it. My friend Gokmen says the same thing. He often remarks, "I solve the problem while asking someone about it."
This happens because when we try to explain an issue to someone else, we’re forced to organize the details in our minds first. To articulate the problem, we break it down and think more clearly about it, and often, that’s enough to find the solution ourselves.
Today, I stumbled across something on Reddit called Rubber Duck Debugging (link), and it’s exactly what I’ve been talking about. The concept is simple: keep a rubber duck on your desk. When you encounter a problem, explain it to the duck. As you try to verbalize the issue and describe your code, you’re naturally forced to organize your thoughts. This often leads to finding the solution on your own.
This method was first introduced in a story in The Pragmatic Programmer. Sure, it might sound a little quirky, but it seems like it could work. Why not give it a shot?
12/2013