I was telling you in the previous post about the XY problem, when someone asks for what they think is the solution to the problem, instead of the actual problem. Well, besides the 5 whys technique, when you are the helper or asking smart questions when you need help, there is one other thing that you can do and it just might help you more than you think.
Rubber ducks are not only good for taking baths, they can also help you with your problem solving or your programming. Of course, you don’t have to use a rubber duck – if you think your teddy bear can ace a duck in a programming contest, go ahead and use the teddy bear.
Don’t think that your duck or bear will magically start spilling out programming advice – they have more of a coaching position – they do not tell you what to do and you will have to find the solution yourself, but they will help and they help by just being the great listeners inanimate objects are.
I will bet this happened to you before: someone comes with a problem and they ask for your help. And as they start telling you about their problem, they will have an “aha” moment and figure out how to solve the problem by themselves.
Taken from “The Pragmatic Programmer” by Andrew Hunt and David Thomas, this approach works because one of the best ways to understand a problem is to try to explain it to someone. Especially when that someone is a rubber duck – you will try harder to explain in detail than you would explaining it to a fellow programmer.
At the end, I will also provide the easy steps one should take in order to successfully employ rubber duck debugging or programming (taken from here) they were just too good not to mention:
Step 1) Beg, borrow, steal, buy, fabricate or otherwise obtain a rubber duck (bathtub variety)
Step 2) Place rubber duck on desk and inform it you are just going to go over some code with it, if that’s all right.
Step 3) Explain to the duck what your code is supposed to do, and then go into detail and explain your code line by line
Step 4) 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.