Developer debugging problem-solving techniques

By Samantha Anderson

Last Updated: February 20th 2023

What do rubber ducks have to do with coding? And why as an aspiring developer you might want to get one ASAP

Have you seen a rubber duck on a developer’s desk?

Maybe it wasn’t a duck but a Funko Pop (those are still popular right?) or even a pet.

I myself have my calico cat who loves sleeping on my desk that I can turn to for moral support.

She’s a great listener and while she may respond sometimes, it’s usually a reminder I owe her some neck scratches for all her hard work keeping her side of the desk warm.

Now you’re probably thinking, “Why is she telling us she talks to her cat? What does that have to do with coding?”

Have you ever heard of the term "rubber duck debugging"?

It may sound silly, but it's actually a powerful technique that can help you troubleshoot and debug your code.

The concept of rubber duck debugging is simple: you explain your code to a rubber duck (or any inanimate object, really) as if it were a fellow developer.

The act of verbalizing your thought process and the logic behind your code can help you identify any errors or gaps in your understanding.

Have you ever asked a coworker a question to only tell them “never mind” before they even opened their mouth because you realized you figured out the answer already?

Exactly.

So why a rubber duck specifically though, you may ask?

Programmers, Andrew Hunt and Dave Thomas, coined the term rubber duck debugging in their 1999 book “The Pragmatic Programmer”.

In the book, there is a programmer who explains his code to a rubber duck.

The idea is that by explaining your code to something that can't talk back or offer suggestions, you're forced to really think through your own thought process and understanding of the code.

Plus, it's a fun and lighthearted way to approach problem-solving.

Here's how you can try rubber duck debugging for yourself:

  1. Grab a rubber duck (or any other inanimate object) and place it near your computer.
  2. Start explaining your code, line by line, to the rubber duck. Pretend like you're teaching it how the code works.
  3. As you explain, pay attention to any areas where you stumble or struggle to explain. These may be areas where you have a gap in your understanding or where there may be an error in the code.
  4. Once you've finished explaining the code, go back and review the areas where you struggled. Try to fill in any gaps in your understanding or fix any errors you may have found.
  5. Repeat the process as needed until you feel confident in your understanding and the code is working as expected.

Rubber duck debugging is an effective and fun way to improve your problem-solving skills and understand your code better.

So next time you are stuck with an error, don't be afraid to grab your rubber duck and start debugging!

Remember, coding is a lifelong learning process, and there's always room for improvement.

And don't be afraid to ask for help, there are many resources available to support you in your journey to become a developer.

Here at Nucamp we believe in the 20-minute rule.

If you can’t find an answer on your own (including help from your rubber duck) in 20 minutes, reach out to your classmates and instructor for help.

N

Samantha Anderson

Marketing Manager

Part Illustrator, part Graphic Designer, and part Digital Marketer—with a sprinkle of sales savvy and a dash of empathy. I'm all about using my creativity to craft captivating stories through both illustration and writing. When I'm not at my computer, you'll find me drawing nature inspired patterns and portraits on my other favorite screen: my iPad. To keep myself inspired (and to get away from my slight tech addiction) I garden, golf, and go on nature walks with my dog and cat leading the way.