Programmer Superpower Number Three

If you have not done so already please read Programmer Superpower Number One, that post sets the tone for this one.
Rubber Ducking!
Have you ever said something out loud and was like “Oh man, that didn’t sound the same way in my head as it did coming out!” That’s because our minds think about words differently when they are said out loud. Rubber Ducking is a method for taking advantage of that mental shift in order to gain a different perspective of the problems we are working on. In relation to debugging our code it can help us to understand what we wrote as opposed to what we thought we wrote.
Rubber Duck Debugging
We perform this specific form of Rubber Ducking by executing the following set of steps.
- Obtain a rubber duck
- Place rubber duck on your desk
- Explain to rubber duck what your code is supposed to be doing.
- Explain to rubber duck line by line what your code is actually doing
At some point in time during or after your explanations to the rubber duck you will get an idea of why your code is not working as expected. Rubber Ducking has the potential to save you hours of time trying to debug a problem.
The Cue For You To Do
What is the cue that should trigger Rubber Ducking? From my observations the general cue for Rubber Duck Debugging looks like the following.
- You have discovered a bug
- You Don’t know what is causing the bug
- You are not typing
- You are staring at your screen thinking
Once most or all of these criterion, especially the not typing one, have been met then that should be your cue to start talking to your duck.
Rubber Ducking Rewards
The rewards for this superpower are pretty straightforward and they are:
- You solve your problem
- You save time solving your problem
- You feel empowered
There are many more but you get the gist of it.
Blog Post Is Too Short
Yes it seems like that and that’s because the other half of Rubber Ducking is too entwined with my next topic post. Besides who doesn’t like snack pack sized blogs right?
Stay tuned for Programmer Superpower Number Four!
