How to Write the Perfect Stack Overflow Question (After Analyzing 10,000)
How to phrase a question in Stack Overflow in order to get better answers
Stack Overflow offers a great interface for accessing all of its data and running any possible query in the questions/answers database. We started using this database to better understand the most common questions about debugging (what we’re trying to solve at Takipi). While learning about debugging through thousands of questions, we also noted an additional bonus: we started better understanding what drives the Stack Overflow community.
This article is the result of researching over 10,000 Stack Overflow questions. It summarizes how you need to phrase and write your question in order to get better and faster answers. When we started running our scripts on the queries’ answers we weren’t sure we’d arrive at strong conclusions. After looking into a few hundred questions, though, we already started recognizing certain distinct patterns that we were seeing over and over again across different programming languages and topics.
You can find a detailed explanation of how we performed the test at the end of the article, but let’s get to the best part first — the results. The main criteria we set for a ‘good’ question were getting high quality answers (from users with high reputation + votes), getting an answer relatively quickly and the number of votes and views.
Keep it short
Probably the strongest pattern we saw across all the different queries and scripts we ran was this: the shorter the question, the more likely you are to get a quick and useful answer. The average length of a ‘good’ question was around 1200 characters (~3-4 short paragraphs), while the average length of a standard question was 1800 characters. The strongest effect of the length was on the view count and votes, where the average length of the top questions was around 50% of that of standard questions.
There’s no such thing as too short, either — really short questions (around 200-300 characters) received the best results.
Title length matters less, we discovered. While we saw the effect of the question’s length across the board, it seems like the length of the title has a minor influence on the quality of the question. The average title length of the top questions was about 5% shorter than that of standard titles (47 characters vs. 50).
#1 influencer – asker reputation
The asker’s reputation has a huge effect on the number and quality of the answers and the speed of reply. It seems that users with high reputations tend to answer more frequently to users with high reputations as well. While we saw that short questions are 50-100% more likely to get better and faster answers, a question asked by a user with a very high reputation is three times more likely to get better answers than a question asked by a user with a low reputation. You might conclude, of course, that users with high reputations ask better questions. It’s definitely true, but we saw some very similar questions asked by users with low and high reputations, and the difference in the quality of the answer was clear.
Some examples: the average asker reputation of the top 100 Java questions with the best answers (high reputation of the user who gave the answer + votes) was 4500 points. The average asker reputation of standard Java questions was 1500.
The average asker reputation of Ruby questions that were answered within 15 minutes was 2400. The average asker reputation of Ruby questions that were answered after 24 hours was 1300.
The average asker reputation of the 100 top viewed Java questions is 3150, compared to average standard question reputation of 1100.
Should I use code snippets?
Embedding code snippets in the question was one of the few parameters we tested that gave very clear results across different languages, but opposite results across different criteria. It seems like questions which include code snippets get better answers — answers with more votes and from users with higher reputation. For example, 87% of the Python related questions answered by users with a very high reputation included code snippets. 64% of the average Python questions include code snippets. Ruby-related questions showed similar results — 91% of the top questions included code snippets compared to an average of 79%.
When it comes to votes, views and time until the first answer, the trend is opposite — for example, 58% of the most viewed Python questions included code snippets. 72% of the questions with an average number of views included code snippets. It seems like it’s related to the question’s length — code snippets lead to longer questions which get lower results.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)