In today’s post, I want to share a trick I discovered: using Stack Overflow to help answer my questions. Before you stop reading, I mean without posting my question at all. In fact, I simply rediscovered the time-honoured tradition of “rubber ducking”. I think Stack Overflow provides the perfect place to rubber duck and I’d like to share my reasoning.
Since I joined the community in 2009, I’ve asked my fair share of questions. In fact, as I write this, my question tally stands at 134. Of these, 99 have been answered by someone other than me. I can’t emphasise enough how helpful the Stack Overflow community has been to me during my career.
What you won’t see on my profile, however, are all the questions I spend time writing without ever pressing “submit”. I estimate that for every question I post, another four get discarded. That’s right: 80% of the questions I start composing in that big, inviting Stack Overflow “Ask a question” box never get seen by anyone but me. Why? Because 80% of the time I answer my own question during the process of formulating it.
I noticed that a while back that I was solving many of my problems (say, 50%) during the process of writing them up as Stack Overflow questions. A first this was annoying: if only I’d thought harder about the problem first, I wouldn’t have wasted all this time preparing a question! Later, it occurred to me that the process of explaining my problem to make it answerable by others was also making it answerable by me. In short, I was using Stack Overflow as a rubber duck.
Rubber duck debugging
Image courtesy of Tom Morris
“Rubber ducking” gets it name from a story recounted in The Pragmatic Programmer. This story features a programmer who found it useful to explain their problems to a rubber duck placed on their desk. It turns out that the act of vocalising the problem and describing it out loud (even if only to a rubber duck) is a really useful way to rethink it, and potentially arrive at an answer.
The magic here is that the act of explanation forces us to go back to basics and think about the problem holistically. To explain effectively, we find ourselves starting at the beginning and proceeding logically through each step, delving into details as we go. This helps to identify and isolate the nexus of a problem – what exactly is going on?
Once we’ve properly articulated the issue, the answer is often not too far away. Or, as the inventor Charles Kettering put it:
A problem well stated is a problem half-solved.
Using Stack Overflow
So rubber ducking is a helpful approach to problem-solving. But why bother with Stack Overflow? Why not just use an actual rubber duck? Or a colleague? For me, it comes down to context. When I’m writing a question in that big box, I’m imagining what people will ask in the comments and try to pre-empt any missing details. As I’m forming the question, I’ll produce a “minimal, complete, and verifiable” example, I’ll go back and systematically check settings, and I’ll re-run everything one last time.
To reiterate my point from earlier, making a question answerable by the Stack Overflow community requires that it is well stated. I’m not alone in holding this view either. The official “How do I ask a good question?” guide on Stack Overflow itself has many suggestions, but my favourite is “Pretend you’re talking to a busy colleague”. You wouldn’t waste their time with a poorly thought-out question, so nor should you do the online equivalent. The venerable Jon Skeet suggests something similar in his blog post on writing the perfect question:
Once you’ve finished writing your question, read it through. Imagine you were coming to it fresh, with no context other than what’s on the screen. Does it make sense? Is it clear what’s being asked? Is it easy to read and understand? Are there any obvious areas you’d need to ask about before providing an answer?
By investing the time in making your question answerable by your peers on Stack Overflow, you’ll make it easier for you to answer the question yourself.
There’s another benefit too: as you’re rubber ducking with Stack Overflow, you’ll gain practice in writing answerable questions. It’s a difficult skill to master and there’s really no substitute for experience. As your questions improve, you may find, like I did, that you start to actually post questions less and less.
Finally, a bonus: if you don’t solve your problem during the writing process, you can still post your question (which by now will be highly answerable).
If you have any tips for rubber ducking with Stack Overflow, let me know in the comments.
