How to Ask a Good Programming Questions


And some examples to help you write that question that gets a good answer!


March 15, 2015

I have never really thought much about how to format a good question. In school, people are often taught, “There is no such thing as a bad question.” I think that is an important thing to remember—the only thing worse than asking a bad question is not asking a question at all. This especially applies in tech, where one can easily burn hours searching for an answer to a question that could easily be answered by someone knowledgeable. Oftentimes, if one knew how to ask the question properly, they already would have found the answer!

That said, I do think it is worthwhile to pursue how best to ask a question with coding issues. This can help a help a potential answerer to know what they should be looking to do to help solve the problem. I have two examples from my posts on the Rock Doves Google + page:

Here is the first:

"Hey everyone. I can't figure out how to make a method operate destructively. For Challenge 1, my pad method works, but my pad! method does not. Would greatly appreciate any help!"

Let’s start with the good. I sum up my problem pretty succinctly. This is very useful for posting in bigger web forums where many people might just scan over your questions. I point out that the major problem is that I do not know “how to make a method operate destructively.

Now, the bad. The advantage of posting in a forum with a specific group of people is that everyone knows exactly what I am talking about when I say “Challenge 1.” However, I did not include enough details in the post. For starters, I should have included code. One of the first messages I got asked for a link to my source code. It would have been best to include that. While copying all o the source code could just inundate readers with too much information, showing the code for the specific method I used could be helpful.

Okay, time for another example:

Hi Rock Doves! I'm having trouble with Release 3 on Setup a Repository. Here's my code, after I created the index.html file in Sublime: cbohl.github.io [master] :> git status On branch master Your branch is up-to-date with 'origin/master'. Untracked files: (use "git add ..." to include in what will be committed) index.html cbohl.github.io [master] :> git add . cbohl.github.io [master] :> git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD ..." to unstage) new file: index.html cbohl.github.io [master] :> git commit ^C Right here, the cursor keeps flashing (I think this is called stalling?) like it's waiting for more input. I don't understand why this git commit won't work. Any ideas? Thanks!

On the good, I included the specific problem: the cursor keeps flashing, waiting for input. This provides the reader with a good understanding of what needs to be fixed. Also, I include code. In hindsight, this may have been too much code for the problem (only the final commit line was causing the problem). However, I did not know that at the time and was trying to give the reader as much information as possible.

One problem with this question is that I don’t really include specifics on the problem in the beginning. Instead, I just tell them what I am working on. As a result, readers may just scan over it, assuming they are unfamiliar with the problem.

Analyzing these examples provides a good way to understand what a good question looks like. One general rule I read online that I liked is that you should imagine you are trying to answer the question you are asking. If you can look at it with fresh eyes, you might easily see why it may be unclear to someone else. Another good rule of thumb is brevity. If a question goes on too long, the reader might get bored and move on to the next question. There is a lot more to asking good questions, but hopefully this exercise will help me to improve in the future.