Rubber Duck Debugging
by Andreea Oproiu • about 1 year ago • 3 min read
Sure, working in software development is cool and all, but it can also give you a lot of headaches if you stumble upon problems you don't know how to solve first-hand.
Any software developer has been there: the code you wrote appears correct, and you think it should work, but it doesn't. Sometimes all it takes to fix something is a typo or a missing semicolon. Other times, it's not even your fault, all it took was updating to a new version because of a flaw in a library you're using. However, you've squandered a few days of your time, and you're getting impatient since the problem is taking so long.
Other scenarios can include bugs, broken code, complicated new technologies or even overlooking the little things — all aspects that can drive a developer crazy, lost among his lines of code.
Rubber ducky to the rescue 🦆
First question — have you tried to explain the problem to someone else? How about to a rubber ducky?
Many developers have had the experience of describing a problem to someone else, perhaps even to someone who has no prior programming knowledge, and then coming up with the answer while doing so. Any discrepancy between what the code is supposed to perform and what it really does can be seen by comparing the two.
In fact, whenever you try to explain or teach a subject, it forces you to evaluate it from more angles and puts everything into perspective. The developer can attempt to complete this without interfering with anyone else by simply explaining to an inanimate item, most commonly in the form of a rubber ducky.
And there's an actual psychological reason behind it, as programmer teacher David Hayes wrote :
"We use ducks and other stand-ins because of the vast difference between the way most humans think and the way that computers do. When you hit a roadblock when programming, it's likely that you're not thinking the way a computer does. Computers are painfully precise. Humans are, generally, forgiving and loose in their understanding. So many of the ‘bugs' and issues you have when solving a problem in your program originate in not being clear and explicit enough in your instructions."
Now, how can you actually use it?
If there's a flaw in your code, but you can't identify what it is, maybe this is the moment when you need a silent friend by your side. Or simply put it — when you get stuck, grab your duck.
Moving forward, this is a simple flow that can help you reach some answers:
- Start with the basics: explain your code and its goals
- Don't skip the details; go through it line by line
- Then move on to all the intermediate states and transitions
- This is the step where your brain starts to unfog and see a possible solution. You're sure to uncover it by going through the procedure, whether it was a typo, the condition, or something else.
Of course, the rubber ducky is just a metaphor for your process of going through the problem from all angles, but it is the most popular go-to item among devs. And who knows, maybe it was a software developer in another life and now has come into this one as your mentor.
Curious to test it out? Email us at firstname.lastname@example.org, and we'll send you our own personalized rubber ducky for free.
News & Updates
Tech Talk and Sangria at Web Summit 2023
by Lucian Corduneanu • 2 months ago• 4 min read
Business Lens on Web Summit 2023: Strategic Insights for Business Growth
by Iulian Arabagiu • 3 months ago• 3 min read
A Dive into Product Growth Dynamics with Lucian Corduneanu at Prow 2023
by Lucian Corduneanu • 4 months ago• 3 min read