How To Debug Something With A Rubber Duck

How To Debug Something With A Rubber Duck

James Crossland

Digital Marketing Manager|Kerv digital

Published 06/07/22 under:

Have a question?

Get in touch

What does a computer programmer and a rubber duck have in common?

 

First things first, we haven’t lost our minds.

Solving a software debugging problem with a rubber duck really is a technique used by a lot of developers.

It doesn’t have to be a rubber duck though. There’s plenty of other names for this technique, often involving either an inanimate object, a puppy/kitten, small child or at a pinch a fellow coder… but our favourite will always be the humble rubber duck.

What Is Rubber Duck Debugging?

So how do you go about solving complex problems with nothing but your wits and a rubber duck?

 

There’s a big difference in how a human thinks to how a computer thinks.

When a programmer runs into a bit of a problem with their code, it’s more than likely because they’re looking at something differently to how a computer will.

Computers are precise, logical, and, seen from a certain perspective… quite inflexible. The counterpoint to that is the human brain which will be quite forgiving of someone explaining something to them, filling in the blanks where required from their own imagination or experience.

That’s why so many bugs a programmer has to deal with will come down to their instructions (code) not being quite precise enough.

 

But what about the rubber duck we hear you cry?

 

Rubber ducking (as it’s sometimes called – “Have you tried rubber ducking it?”) helps a programmer get round that problem.

The programmer knows the intent of the program, the computer doesn’t. Your rubber duck then, will help bridge that gap.

In essence, if a programmer hits a roadblock, they’ll explain what they’re trying to do, and the code they’re doing it with, line by line, to the rubber duck.

The process of having to slow down and explain what’s happening, line by line, to an object that knows nothing about programming, often helps the coder identify the problem pretty quickly by simultaneously explaining what it’s supposed to do and what it’s actually doing.

It also helps to change a programmers perspective somewhat as what they’re doing is actually ‘teaching’ the rubber duck, forcing them to view their code from a different angle and thereby offering a deeper understanding.

The use of the rubber duck also means this can be achieved without having to disturb anyone else… always a benefit when you’re trying to hunt down an embarrassing mistake or glitch in your code.

How To Rubber Duck Debug

Now you know the theory, applying it to a practical method couldn’t be easier!

 

  • Step One – Beg, borrow, build or steal a rubber duck from somewhere – The default yellow variety is fine but let’s be honest, if you’re going to be talking to a rubber duck, then the more outlandish the better.
  • Step Two – Place said rubber duck somewhere prominent on your desk – Feel free to put it in a glass case you can break in case of emergencies (depending on how often you have to check your code anyway).
  • Step Three – Upon encountering a problem, explain to your duck what it is your trying to achieve then walk it through your code a line at a time – don’t skip any details, rubber ducks love details.
  • Step Four – Enjoy your moment of revelation as you explain to the rubber duck what you’re doing and realise that isn’t what you’re doing after all.
  • Step Five – Quickly explain to all your colleagues you haven’t gone insane.

 

The reason rubber ducking works so well is that by following this process you’ll almost always find your problem, normally a small typo like a misplaced div – The duck always reveals something!

The Psychology Behind Rubber Duck Debugging

The reason rubber ducking works so well is that explaining something to someone else (in this case your faithful rubber duck) causes an actual shift in your thinking process.

The first thing to happen is that you’ll be forced to slow down and pay a lot more attention to what you’ve typed as most of us will think a lot faster than we can type (or code). Having to verbally explain what you’re doing will likely make you a lot more accurate.

 

The second benefit to rubber ducking is that you’re forced to work to your rubber ducks level or knowledge of coding (and rubber ducks make awful coders… trust us).

Your rubber duck won’t know nearly as much about the problem as you do. Simplifying the problem to a level where a rubber duck can understand it will almost always reveal the solution.

Where Can I Get My Own Rubber Duck?

Are you telling us your bathroom doesn’t already have a rubber duck you can ‘borrow’ to talk code with?

Never fear, they’re incredibly easy to buy online… but we still think there should’ve been one in your bathroom already!

Related Articles

You might also be interested in

From our world to yours

Going Beyond The Theory: Kerv Digital & The DVSA

From our world to yours

Life @ Kerv Digital As A Performance Analyst

From our world to yours

Four ways to defend against Cyber Criminals attempt to infiltrate Contact Centres

From our world to yours

Microsoft Cloud For Nonprofit: Fundraising & Engagement

From our world to yours

Kerv Group brings rich, actionable insights to bear on improving performance management...

From our world to yours

4 ways to integrate your Contact Centre and CRM to deliver brilliant...

From our world to yours

Kerv Digital 2022 Wrap-Up

From our world to yours

Life @ Kerv Digital As A Recruitment & People Analytics Manager

From our world to yours

CX Translate Opens the Door to International Understanding in Cross-Border Contact Centres

From our world to yours

Cloud Confessions: Q&A with CTO on Communications Compliance

From our world to yours

Helping With Hackathon Fundamentals

From our world to yours

Kerv Digital & Microsoft Solutions Partner Designations

From our world to yours

Life at Kerv as a Billing & Operations Co-Ordinator

From our world to yours

Deciphering Digital Transformation

From our world to yours

4 Things to Bear in Mind About Microsoft Teams Policy Based Recording

From our world to yours

Understanding EX: Achieving the utmost from workforce engagement management (WEM)

From our world to yours

Working Wellness: More Kerv Digital Benefits

From our world to yours

Cloud is not a destination

From our world to yours

How SD-WAN enables service provider flexibility, enhancing connectivity and reducing cost

From our world to yours

Taking the guesswork out of managing your future bandwidth demand

From our world to yours

Application Performance: User Experience

From our world to yours

Rapid Site Deployment and its Impact on Retail Profitability Across Store Locations

From our world to yours

Why your network infrastructure is key in mergers and acquisitions

From our world to yours

Data Platform Pragmatism

From our world to yours

Will SD-WAN really save money and why you must take a proper...

Have a question?

Leave your details and a member of the team will be in touch to help.
By pressing send, you agree to our Terms and Conditions and Privacy Policy.
This field is for validation purposes and should be left unchanged.