Saturday, April 14, 2018

The Art of Asking Good Programming Questions

Background
Software development is a field of asking questions and answering questions, which is why knowing how to craft a good question is extremely important. Some of my free time at home goes into answering questions, and I'm usually happy to do so. It's why I joined the programming community: to discover answers and to help answer. It's fun seeing how people progress and to help them move forward with complex concepts.

A Bad Question
You know what isn't fun? When someone posts "I need help" with zero clarification on what they need help with. Then, someone has to come in and ask that person what they need help with. This is how questions get ignored or left unanswered. It is honestly frustrating to have to follow up with a person over and over again until a problem arises. For example, let's pick apart the following (real) question below from a thread titled "Needing help":
I'm trying to set up a private server and i am having some issues. I've watched tutorial after tutorial and its just not wanting to work, i need someone to help me get this figured out.
When asked what errors or problems they were seeing and for details, they responded with:
I am having trouble getting the server online.
Great. What. Is. The. Error.
 A friend at school told me i may need to forward ports.
Never does this person post an error they're seeing. Is the server returning a programming error like "password = yes" from MySQL or is a null exception being thrown? Does the client connect or does it hang for a few seconds before timing out? Does the client connect and hang indefinitely with a programming error occurring? Does it say their password is incorrect? We'll never know after the already 3 day exchange I had with this person.

Other horrors include non-questions like "I want code that does this". Don't demand code in a programming section. That's like demanding art in an artists' community. You will likely not get an answer, be insulted heavily, or asked to leave.

A Good Question
So, we looked at a bad question, what would be an example of a good question? A good question is one that can explain exactly what they have observed. If there are errors or an expected behavior that they're not seeing. They disclose the actual behavior of the problem with detail, and how they got to that error (such as repeat steps on producing the error). Here's an example of a decent question (I couldn't find a good question):
I would like to know where i can find that code for dragon ball notification. Like when someone is hunting, a dragon ball dropped and just after that a message notification appears on screen "Dragon Ball Dropped". i have no idea what source version is using that private server but i think i can be implemented with some client modifications.
The English may be a bit broken, but the person asking defined the expected behavior of what they're looking for, what they know and don't know about the problem, and clearly asked a question of "where can I find this effect in the client". They even mentioned how they believe it can be fixed, showing they're pursuing the answer on their own outside of your help and just need a nudge in the right direction.

Conclusion
Here is what makes a great question:
  1. A summary of the problem
  2. Pictures and copied text of the exact error / problem being observed
  3. A description of the expected behavior
  4. A description of the actual behavior
  5. Repeat steps for how you arrived at this problem
  6. How you have tried to fix the problem
  7. What versions of software you're using 

Knowing how to ask a good question will help you get answers faster, and help others in the community work with you on solving your problems. We're here to help and here to work with others, and knowing how to ask good questions can help you enjoy the community as well.