Rubber Duck Debugging

Over on Thoughtful Code I recently covered the topic of “rubber duck debugging.” It’s a pretty simple procedure but one I love because it works surprisingly well. Here are the basic steps:

  1. Explain your (broken) code and its goals, generally. Don’t worry about details, just set the context for your duck.
  2. Line-by-line, explain what the flow of the whole function or method that’s not working is. Don’t skip details, ducks love details!
  3. If your duck friend hasn’t spotted it yet, be sure to explain all the intermediate states and transitions in detail.
  4. Find your (stupid, obvious) solution! The reason we so love “rubber duck debugging” is that (typically) in the process of doing this, you’ll find your problem. You made a small typo. You were operating on the wrong variable. Your if condition was checking the opposite of what you thought. Something is likely to be revealed.

You can read all of that, and my Malcolm Gladwelling about how it works in “Rubber Duck Debugging: The Psychology of How it Works.” I’m thought-leadering so hard right now! 😂

Add a Comment

Your email address will not be published.