How To Ask A Question on StackOverflow

 
Stackoverflow qn.png

So many devs hestitate to ask questions. It can be hard to know where to start and how to formulate a good question. Its easy to think that your questions is "smart" enough to solicit a response. Let's knock down those doubts and learn how to write an excellent Stack Overflow question!

Stack Overflow is THE place to ask and answer coding questions. It's a thriving online community of developers where you can post any programming question and receive answers and support from over 50 million developers around the world.

Asking Questions is Underrated

One of the most common mistakes that I've seen my programming students make is avoiding asking questions or Googling answers to problems. A lot of beginners view these approaches as cheating, or are embarrased to admit that they don't know something.

Why You Should Ask Quesions on Stack Overflow

I cannot overstate this enough: aksing questions and Googling things is a BIG part of programming! As a professional developer with several years of experience under my belt, I Google programming topcis and questions every single day.

When you're learning to code, you're going to have lots of questions. While there are a number of places you can take those questions, Stack Overflow is probably the most popular platform for posting programming questions. In fact, if you've every Googled a coding question, you've probably read some Stack Overflow questions and even used some of the answers to solve your problem.

Asking a question on Stack Overflow allows you to:

  • Sharpen your question-asking skills (and remember this is an important skills to hone as a programmer).
  • Give back to the coding community! You are almost certainly not the only person who will ever have a given question. Asking on SO adds your question and any answers it receives to the general knowledgebase shared by all developers. Next time someone Googles a similar question or topic, your question and its answers just might come upt!

Let's learn how to write a strong, clear question that will be sure to get some answers.

Sign Up for Stack Overflow

If you don't already have a Stack Overflow account, make one. Not only can you ask questions once you have an account, you can answer them too!

Writing Your Question

There are two types of questions you might post on Stack Overflow:

  • How Does X Work?
  • How Can I Solve X Specific Problem?

When writing either type of question, the main thing to rememer is:

Always Be Specific!

Let's learn how to write a clear, concise and specific question, starting with the first type of question.

Question Type 1: How Does X Work?

You're learning about HTTP requests and the different HTTP request methods for the first time. You have a basic idea of how it works but you're struggling to understand the difference between some of the different request methods. It's time to ask a question on Stack Overflow!

It might feel like we a struggling with a general topic, HTTP requests. So, you might be tempted to ask a question like:

(Don't do this:)

Help! I don't get HTTP requests! Can someone explain them to me?

This kind of question won't be well received. It's far too open-ended. You're not putting out a specific ask that developers can respond to.

How to Come Up With Your Question

How can you take your general confusion and turn it into a specific question? Try this:

  1. Write down a summary of what you do understand
  2. Write down a set of general questions
  3. Pick one general question and shape it into a more specific question.

Then you're ready to write your post!

How to Write Your Question Post

When you're writing your post, include the summary of what you know. This gives your question the context that readers need to provide a strong and helpful anwers. A good post consists of two parts:

  1. Summary of what you do know
  2. Your specific question

Here's a great example of a well-written (and popular) Stack Overflow question on the topic of HTTP requests:

so_http_question.png

This poster starts out by summing up what they know about PUT and POST requests and finishes with the specific question:

So, which one should be used to create a resource? Or one needs to support both?

This clear and pointed question was up-voted over 4,000 times and received a number of helpful answers.

Question Type 2: How to Solve A Specific Problem

You're working on an app that contains an employee database. You're responsible for building an employee search feature and you've hit a snag! You've been stuck on this bug for at least a day and you're totally stumped. It's time to ask a stack overflow question!

Since this question is specific to the app that you're building, the technologies and libraries you're using and the code you're writing, you need to provide lots and lots of detail.

How to Write Your Question

  1. Describe the bug that is occuring
  2. Describe the circumstances underwhich the bug is occuring
  3. List all of the technologies and libraries you are working with
  4. Ask your specific question.

Here's a great example of this type of SO question:

so_debug_question.png

This poster explains the problem they are having, shows us a code snippet that further illustrates the problem, lists out the technologies they are using and asks a specific question:

How to pass "Null" (a real surname!) to a SOAP web service in ActionScript 3?

Get Asking!

Now you understand just how critical it is to ask questions as a programmer. With the guide provided here, you're ready to ask clear, concise and specific questions that will be sure to attract helpful and engaging answers. Start asking!