r/AskProgramming • • Dec 13 '20

Other Rubber duck debugging?

Stumbled upon an article that read when coders get stuck they tend to fall back on a rubber duck to debug. Is this actually true? How many people here actually practice this method?

58 Upvotes

41 comments sorted by

View all comments

69

u/A_Philosophical_Cat Dec 13 '20

I don't use a literal rubber duck, but it's definitely a thing where the act of explaining the problem to someone, even someone with no useful feedback to give, can help you come up with a solution.

Typically, I use a friend or coworker, but talking to a rubber duck would be equally effective.

28

u/hadidotj Dec 13 '20

My big "break through" moments are in the shower after dreaming about it all night........

26

u/flubba86 Dec 13 '20

After 5 years as a senior developer, last year I finally recognized the patterns I go though when stuck on a problem, and how to take advantage of it.

First, I allocate a slab of extra personal time to the problem, ie. I'll stay up late one night after dinner and work from 8pm till 1am. At around 1am I find my mind simply cannot crunch on it anymore and my brain starts to spin in circles (I recognize this when I keep forgetting which browser tab I'm supposed to be reading, or I forget which file I'm currently editing). Then I go to bed and sleep on it. The more sleep the better. It helps if I can sleep in until past 8am the next morning.

I will usually dream about the problem because its still in my head when I go to sleep. When I wake up, I jump in the shower, and while in the shower I will think about who can I draft an email to about this problem? eg. if its an open source library or tool I'm using, I'll think about who the maintainers are, or if its an internal project I'll think about which of my colleagues have experience with what I'm dealing with.

Then after breakfast I will sit down at my computer and draft an email to that person, (but leave the to: field blank, so I don't accidentally send it). I will write down my problem in excruciating detail. Including what I'm doing, why I'm doing it, everything I've done up to this point, what I'm attempting to do now, sample code snippets, what I expect the result to be, what I think my problem is, and how I think I might be able to solve it.

Usually during drafting that email I will need to double check some things. I don't want to look like an idiot with what I'm saying, or missing something obvious. So I double check my facts, double check my code, re-read some documentation, re-run my code, copy&paste some error messages. This is a critical process to go through, that I call sanity checking (and especially needed after a late night of going insane).

So by this point, 99% of the time I will have solved my own problem. At some point during writing the email and sanity checking myself I will have either stumbled across the problem and fixed it, or more likely I'll have discovered some fundamental logical flaw in what I'm doing and why I'm doing it that way, then change my approach to better fit the problem.

This pattern of events has happened so many times now, I've come to rely on it as part of my workflow. I think it could be considered a form of Rubber Duck debugging.

2

u/bstiffler582 Dec 13 '20

Not necessarily in the shower for me, but almost always AFK. E.g. while eating, walking or driving.