DEV Community

Cover image for Rubber Duck Debugging
Kristi
Kristi

Posted on

Rubber Duck Debugging

What is debugging?

Debugging is the process of finding and removing bugs(errors) in a software code.

What is Rubber Duck Debugging?

Rubber Duck Debugging is a method in computer science of debugging in a way by articulating a problem speaking in natural language.

What does that mean? 🤔
You start coding. Then an unexpected error happens. Something is wrong with your code so you have to debug. This is the moment that rubber duck debugging is needed.
Grab a rubber duck or if you don't have one just grab an object and explain to the object your code line by line. By explaining and speaking out loud your code, you may understand what is wrong with it.
You may not find the answer on the first try but this method is effective and has been proved by many programmers.

I know that there are so many tools for debugging BUT the rubber duck debugging method will help you to understand your code and learn more.

Conclusion

This was a basic explanation for the rubber duck debugging method. Hope you got the idea of what rubber duck debugging is.

References
Rubber Duck Debugging Website
Useful website if you want to talk with a duck and explain the problems of your code

Debugging

Rubber Duck Debugging

Top comments (4)

Collapse
 
steinbring profile image
Joe Steinbring

I can't begin to count the number of times that I have found myself explaining a chunk of code to someone only to realize what the problem is, myself. Since early in my career, I have kept a Superman figurine on my desk and if no one is available to lend me their ears or I don't feel comfortable, Superman is my go-to debugging buddy.

Collapse
 
pinotattari profile image
Riccardo Bernardini

Never used a rubber duck, never felt the necessity.

If I wrote the code, what it should do it is clear to me; in most cases the bug is just something silly.

If the code was written by someone else and it is so obscure that I need to do some "reverse engineering," then I just keep notes and write diagram like a "conspiracy mad" in a movie.

Collapse
 
curiousdev profile image
CuriousDev

Thanks for this article. I agree, that describing in spoken or thought words the code can help to understand it better.

Collapse
 
besi profile image
Besi

Well written!