'How can I ask better questions on Stack Overflow beyond reading the "How do I ask a good question?" page?

I'm an enthusiast programmer. I usually ask questions on Stack Overflow when I can't solve hard programming problems myself. But when I ask questions, people usually start downvoting them (my worst question with 10 downvotes which banned me from asking a few days ago).

If it is a good question, people usually only give one or two upvotes. I have read the How do I ask a good question page but I think I fulfil all requirements stated there. Here is one of my good questions which has only 94 views in 2 months and only one upvote (at the time of asking). According to the Help Center, I should add correct tags and an informative title, but I think people don't see questions when they have too many tags or are too specific. Usually, they just come and downvote (sometimes even without reading the full question), but don't explain why my questions deserve them.

What should I do? Should I use fewer tags? It is painful to get anonymously downvotes and having my questions closed.



Solution 1:[1]

In an ideal world, info in "How to ask" should be enough. However, given that many users ask bad questions on Stack Overflow, one additional powerful technique is to set your questions apart from the bad questions. Try to think like a user who reads 100 questions per day, 90% of which are junk. Try to convince that hypothetical prejudiced user that your question is different (not junk). Easier said than done; however, here are some ideas:

  • Make sure your question doesn't look like homework; that answering the question is the only missing detail in your current task, and you can do all the rest yourself
  • Prepare a minimal, reproducible example; if not needed, make sure people understand why it's really not needed
  • If possible, point out a clear way to verify an answer is good (e.g. say "How to do X with O(n) complexity", don't say "What is the best way to do X")
  • Show that you really care about the answer to your question (e.g. if people ask for clarifications in comments, do clarify by editing the question)
  • Avoid obviously bad things, like pictures of code, bad spelling, etc. "How to ask" already mentions this.

The above reflects my experience with bad questions; it might be different from everyone else's, but this is at least something.

Solution 2:[2]

One of the best ways to improve your writing (for Stack Overflow questions, or anything else) is to read what others have written. Find questions that generated lots of good responses and study them to see how they have used tags, how the question is structured, etc. Do the same for questions that were received poorly. After a while, start reading through newly-asked questions and try to predict how well they'll be received. If your predictions are mostly correct, then it's a sign that you understand how good questions are written.

To bring more eyes to your question, you have to understand how people find your question in the first place. This includes (no particular order):

  1. Listed on the home page
  2. Listed in the feed for a tag that someone is following
  3. Listed on the "questions with bounties" page
  4. Featured in the "Hot Network Questions" sidebar
  5. Listed in the "Related" sidebar
  6. Found by searching on the site
  7. Found via external search engine (Google, etc)

Some of these are out of your direct control (like #4), but some of them can be used to make your question more visible. #2 is why using the appropriate tags is helpful. Adding a bounty is generally considered the best way to draw more attention. The last three are tricky because they're dependent on what other people happen to be looking for. Try to think about what terms other people would use when searching for answers to questions like yours and include those terms/phrases in your question. The home page used to list questions by "most recently asked", and asking at certain times of day would attract more views than others. The front page feed is now tailored to each user's specific preferences, so it's a lot harder to break into that list.

It's also important to make your question something that other users want to read. Users don't always have time to read an extremely long or detailed question. Similarly, users are less likely to take the time to write answers when the question requires answers that are long, open-ended, or that require writing a lot of code. The way that points are structured on this site incentivizes people to answer a larger number of smaller, simpler questions over a smaller number of longer, more difficult questions.

Speaking of the point system, I've found that having a higher reputation makes it more likely that your question gets read and responded to. The site has lots of users who create an account, ask a low-quality question, and are never heard from again (they don't even mark an answer as accepted). Because of that, the temptation for a user with limited time is to read the questions of higher-reputation users since they're more likely to be better questions. Spend some time answering questions and build up a decent-sized reputation pool. Aside from making people more likely to read your questions, you'll be better suited to add bounties as needed.

Specifically regarding the question you linked above: your comments indicate that you're hoping for answers that are better than the existing one. In my experiences, few people take the time to add an answer to a question that already has an accepted answer unless the accepted answer is incorrect, missing something critical, or is no longer the best solution due to changes in technology (new language features, etc). The question is seen as not needing an answer any more, and the asker is much less likely to return and upvote/accept a newly-posted answer. This is even more true when the asker answers their own question. Your answer there is extremely long, which means very few people are going to read all the way through it, decide that they can do better, and take the time to write up a new answer. That's definitely not saying that your answer is bad, it's actually one of the most complete and detailed answers that I've seen in a while (good use of ASCII art by the way). That question, as it currently stands, appears to be answered and complete, and is thus unlikely to attract new answers.

Solution 3:[3]

The question you link as worst question, that has 10 downvotes and is deleted, is an easy one to crack. For starters, each tag has their own culture, because different people roam different tags as their experience differs. But so do their motivation, patience and skills.

You happened to post in the C++ tag, where the unforgiving nature of the compilers seems to have rubbed off on its users.

The question basically asked:

Why is a unoptimized function call in a loop slower than having the same code inline?

Searching Google for C++ function call overhead site:stackoverflow.com yields 26,000 results, and C++ properly benchmark code site:stackoverflow.com has 5,000 hits.

This could warrant downvoting your question, because it doesn't show that you researched those or related terms. If you did actually do research, but didn't understand what you found, then mention that as well. Explain what you do and don't understand, this helps potential answerers.

The commenters could have linked you to some canonical questions that they know explain the relevant stuff well, found from the aforementioned or other searches. They didn't search or link for you, but they did go out of their way to prove that your code was useless and would be optimized away entirely instead.

While commenting (paraphrased) "Your code doesn't take 2.5 seconds, it takes 0 when optimized" even then they're barely helping you, more like taunting. They care enough to copy your code to an online compiler and prove that, but don't bother explaining why a compiler may do so if it finds dead code whose implementation is trivial and its results unused.

tl;dr: show your research, and know your audience. You do the latter by lurking more and getting the feel of a room, which more people should do online anyway.

Solution 4:[4]

I want to add to what the other answerers have posted from a different perspective:

Stack Overflow is a collection of knowledge. It's not mainly for direct help (tutoring) but indirect help: by providing information that you can find e.g. over Google. The whole Q&A-thing is the way to aggregate all this information.

It's even mentioned in the very first sentences of the Tour:

[...] With your help, we're working together to build a library of detailed answers to every question about programming.

So when you post a question that is e.g. a duplicate (or is not useful for future readers in any way), then it's not useful for Stack Overflow and its intention and therefore rightfully downvoted and closed. Some people take that more serious, so don't take downvotes too personal and try to see the question from their perspective.

When you post something that is kinda similar to other questions, your question most likely won't receive many upvotes. The questions that receive many upvotes are the ones that actually bring new information to Stack Overflow. They are upvoted because they are "useful", not necessarily because all are technically better than your question.

Then there is the luck-factor. Sometimes just the right person must click on the right time on your question to write a good answer. Sometimes you get just unlucky and those other viewers were not in the mood or don't know the answer or whatever. It's similar for the viewing-count and the amount of upvotes.

What I want to tell you is that following the recommendations in the Help Center is not a guarantee that your question is ideal to gather many views and upvotes. Maybe your question is just not "new"/"original"/"interesting" enough to attract many upvotes and views. Or the question is useful to you but not to future readers and attracts downvotes.

One tip I can give is: write your questions while having the idea behind Stack Overflow in mind. How would a future reader see the question? Does it get straight to the point, exactly what the reader was searching for? Is it well written and formatted, which improves readability? Is it easy to distinguish from similar questions?

The ideal is that someone searches for an answer because they have a question and Stack Overflow provides the identical question with the corresponding answer to them. Nothing more, nothing less. Not 10 times the same thing. Not 10 times something in low quality or not focused on what the searcher is searching for.

As you might have guessed: most questions have already been asked and answered. You can't artificially "make" your question something "new" to attract views and upvotes. What you can do is coming up with high-quality content and hope for the best.

Solution 5:[5]

I wanna add some points that will help you in asking questions.

  • Always research first. This is vital, an important number of questions have already been answered here. Search here, search outside on the web, read documentation, try debugging. If you didn't come up with a solution in SO, but found the solution somewhere else, it is good that you ask and answer your own question, so we have the answer here!
  • Give insight on how you expect a good answer to be. Since you have done your research, you might have found potential answers for your question, that didn't meet your bar for some reason. Including in your question restrictions that clarify why your research didn't help you out, will avoid people answering the same stuff you've come across once and again. Furthermore, if you have special needs, like not using external frameworks for example, including these restrictions will also save time from everyone.
  • Keep in mind the time constraints of the people who will reply to your questions. Many of us in SO are people who try to help out others in their journey, but our time to help out is finite. If a question requires too many effort for us to answer, we'll probably skip it and find a better question. It's not even about how many time we can dedicate to SO, it's more about being productive, if a question takes 1 hour to reply, unless it's somehow exceptionally interesting, we'll probably move on to another one that takes just 10 minutes, that's 6 questions we can answer in the same time span. When asking, ask yourself: "if I had the knowledge to answer its question, would I be able to quickly get an idea of the problem and provide a valid solution?". This means short, concise and readable questions, where clutter is avoided but all relevant information is still there.
  • Keep editing your question, and even the answers While you have no answers, you may be still researching, probably. And maybe you come across more invalid solutions, or realise that you have new constraints, or that you can clarify something (probably because some user has asked you in the comments). Keep updating your question with all this new research, it will help in finally getting the answer you need. Not only that, but even beyond the time when you get the answer, perhaps you pull the cord and find other insights that can improve the answer. Edit the answer in that case! Your posterior research is very valuable to other users that come up with the same question.
  • The title of the question is very important! It's how you get people hooked to your question. The title of your question should already give me the feeling of "oh, I think I know how to do this". Maybe when reviewing the question content I see that I didn't know, but making unambiguous titles will attract the right people to your question.
  • Asking is not always your best choice. If your question was already asked in SO, but has no answers, or you dislike the current answers, start a bounty on that question instead. Not always the solution to your problems will be asking in SO, sometimes, the amount of detail that you need to provide to have a minimal, reproducible example, is just so insane that people will not take the effort to try to answer. Or you're working in a project under NDA and asking a question would mean either leaking relevant information about the system you're building, or providing insufficient detail that makes the question unanswerable. In that case, you'll have to research on your own or ask a colleague -probably Stack Overflow for Teams is a better fit in this case-.

Solution 6:[6]

Several years ago, I drew on personal experience, various SE-network questions & answers, and some "formal" documentation (ie from various companies' "how to file a support/bug case") into an eBook that covers this: Debugging and Supporting Software Systems

Here's what you need to do:

  • Have a "real" question - something you've actually run into (even if you have to sanitize the data/situation)
    • Parallel to this: it [probably] should not be a "homework question"
    • ...Though some "homework" questions are actually "real" questions
  • Alternatively, have a "real" question that's a personal curiosity (how/why does this thing to that action)
    • ...So long as you're not only asking these, you should be good
  • Structure your question in a clear, easily-followable format (some of this is drawn from that eBook's second chapter on "Helpful case titles and descriptions")
    • describe the basics of what you are trying to do, and where you are trying to do it
      • give a useful tl;dr question title like, "Cannot start Tomcat6 on Ubuntu 10.10 x64 server"
    • explain what you've already done/tried
      • "After successfully running sudo apt-get install tomcat6 on my Ubuntu 10.10 x64 server, Tomcat will not start"
      • "Debugging steps taken: ..."
      • "The suggestion at askubuntu.com/questions/90823498237... did not work"
    • explain any errors/messages you've gotten
      • "The following message is showing in /var/log/tomcat/stderr.out: ..."
    • explain the end state you're trying to achieve
      • "I am trying to run Goorbleblurk Whiznag 7.2, which requires Tomcat6"
  • Don't:
    • Tell anyone "what you know is not wrong" - unless you can document that you've tried it already, and it didn't fix your issue

Lastly

If you have the time, and ability, take the answer(s) you receive, and write them up somewhere - an internal knowledge base, your personal blog, into a status report email ...

So that you not only acknowledge the help you received, but also save someone else (likely yourself) time in the future.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonathan Leffler
Solution 2 Peter Mortensen
Solution 3
Solution 4
Solution 5 Marc Sances
Solution 6