Sensidev logo
Hero Image

Rubber Duck Debugging

by Andreea Oproiuover 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:

  1. Start with the basics: explain your code and its goals
  2. Don't skip the details; go through it line by line
  3. Then move on to all the intermediate states and transitions
  4. 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 team@sensidev.com, and we'll send you our own personalized rubber ducky for free.

Dev Thoughts

The Product Owner’s View Building a Streamlined Transport Management System

The Product Owner’s View: Building a Streamlined Transport Management System

by Alexandra Voineaabout 1 month ago5 min read

Mobile App Development in Action

Improve Your Dev Journey: Essential Skills Beyond Just Coding

by Dragos Ispasabout 2 months ago5 min read