Rubber Duck Debugging

Image credit: Amazon

I have been in a similar situation multiple times - where in I was stuck on a problem. To get a solution, I would want to reach out for help. So, I would start to write it down - as it could post it in StackOverflow or send it as an email to my friend/colleague. While I am writing the problem down, I try to set the context and elaborate on the problem statement - after few iteration/reformatting/edits - its strange that I would have found the solution. Oops-What happened???

Stepping back and looking at it, what had happened is - while we try to explain the problem to someone (in writing) - we try to remove all the clutter and focus on the actual problem - with the intent to keep the email shorter and digestable components, so that the audience/reader is not overwhelmed. But, in the process we have a better clarity of the core (only) problem we are trying to solve. When that clarity comes up, more often we get closer to the solution.

BTW: I never knew, there was a name for it - “Rubber Duck Debugging” until I heard it from scott hanselman in one of his podcast. And there is a website rubberduckdebugging for it.

Snip from the site:

  1. Place rubber duck on desk and inform it you are just going to go over some code with it, if that’s all right.
  2. Explain to the duck what your code is supposed to do, and then go into detail and explain your code line by line.
  3. At some point you will tell the duck what you are doing next and then realise that that is not in fact what you are actually doing. The duck will sit there serenely, happy in the knowledge that it has helped you on your way.

Well, I had to buy one rubber duck, as I wasn’t able to negotiate to lease one with my 7yr old daughter 😉

The next time you get stuck on a hard issue, take a moment and write down exactly whats going wrong as if you were going to explain it to someone else, you may just notice exactly where you are going wrong and even if you dont, at least you have a question all ready for submission to StackOverflow…

Jacob Aloysious
Jacob Aloysious
Software Enthusiast

35yr old coder, father and spouse - my interests include Software Architecture, CI/CD, TDD, Clean Code.

Related