Rubber Duck Debugging

What is it?

Rubber Duck Debugging is a proven technique which can be beneficial in helping you make progress when your code isn't quite working properly.

The concept is simple:

  1. Grab your rubber duck (you were given one at CoP #1. But if you don't have it with you grab something else - a teddy bear, a lego minifig, your favorite coffee cup. It really doesn't matter).
  2. Set it down next to you while you are sitting at the computer.
  3. Explain to the duck that you are having difficulty and your code doesn't work.
  4. Tell the duck OUR LOUD what the code is supposed to do.
  5. Step through your code one line at a time and explain OUT LOUD to the duck that line of code.
    1. What is it supposed to do?
    2. Why does this step help you in the big picture of the program?
    3. What kinds of data are you working with?
  6. The whole idea is that OFTEN in doing this process - in talking outloud to your duck. You hear yourself say something and your brain clicks in and says "that's not right" or "it would do that if I added this" or "wait. that isn't the right command/data"

It may seem silly to talk outloud to a TOY. But this actually DOES work with some regularity. It may feel silly. But if it works, why do we care?

 

Resources