O
28

Appreciation post: the rubber duck method for debugging saved my 3 hour headache

I was stuck on a simple JavaScript loop last night for like 3 hours. Could not figure out why my array wasn't printing right. I tried console logging everything, checking the docs, even rewrote the whole thing from scratch. Then I remembered reading about talking to a rubber duck. So I grabbed a little plastic duck off my desk and explained my code line by line out loud. Halfway through explaining the for loop condition, I realized I had a off by one error. It was that obvious once I said it out loud. Fixed it in 30 seconds after that. Has anyone else had the rubber duck thing actually work or was I just lucky?
2 comments

Log in to join the discussion

Log In
2 Comments
kim_martin
kim_martin14d ago
Oh geez, the rubber duck method is basically my coding therapist at this point. I've definitely had that moment where I'm explaining something ridiculous like "and then this variable should definitely be null here" and suddenly my brain is like wait no it shouldn't. It's almost embarrassing how well it works for something so silly. I think the whole point is you can't hand-wave past the logic when you have to say it out loud to a tiny plastic audience. Plus the duck doesn't judge you for your dumb mistakes, which is nice.
6
phoenix_adams60
Oh man, the rubber duck method is legit! I had almost the same thing happen with a CSS grid issue once. Did you notice it helped more because you had to slow down and actually say each part out loud, or was it more about having an "audience" even if it's a toy?
3