blogs & Things

How To Debug Something With A Rubber Duck

blogs & Things
wooden toy

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!

More blogs & Things

More blogs & Things


James Crossland in NonProfit

AI + Automation: Reducing Donor Churn & Maintaining Sponsor Interest

Churn management is a vital element of any marketing strategy, and the NonProfit sector is no exception. Knowing what to track and having a joined up view of all your donations data is vital for getting this right, and also opens the door to building innovative data-driven campaigns.   At our recent DataScience and Transformation in Charities […]


James Crossland in NonProfit

Dynamics 365 In NonProfit’s

Charities have unique funding concerns, and an obligation to spend as much as possible on their chosen cause. However, an investment in technology can offer ROI in the form of more than just improved fundraising. Dynamics 365 can help rework complex business processes, ensure compliance with stringent safeguarding and financial regulations, as well as consolidate […]


James Crossland in Tech

8 Ways Your Business Can Increase Turnover With Big Data

Understand how Big Data and Data Science can transform your business…   Big Data is the phrase that’s used to categorise any data that’s too large, complex, cumbersome or complicated to be managed and processed by conventional technology. To put that into a relatable context; being able to recommend your customers content, products or offers based […]


James Crossland in NonProfit

How To Reduce Donor Churn In NonProfits

Reducing Donor Churn doesn’t have to be a big task but does need to be a fundamental part of a NonProfit’s day to day processes   What Is Donor Churn? Donor Churn is the likelihood of an individual stopping their donations to a charitable cause for a variety of different reasons resulting in the non-profit organisation […]


James Crossland in Tech

Agile: Cutting Costs, Improving Quality & Accessing Talent

After using Agile to develop software products for several years, we thought we’d share the challenges we encountered at the start, what we did to change and the results we saw (which were ultimately uplifts in quality and efficiency)…   My development team has been using Agile to develop software product since 2007. Personally, I’ve seen many […]


James Crossland in Tech

UI VS UX

What’s the difference between UI and UX?   Simply put UI (or User Interface) are the pages, screens, buttons, icons and any other visual aspects of a website or App that let you interact with it… or to expand on that into the non-virtual world… UI is how you experience using something – For instance in opening a fridge, […]


Send us a Message






    Call cloudThing
    0121 393 4700
    DEVELOP • DYNAMICS • DEVOPS • DATA
    By pressing send you agree to our Terms & Conditions