site

press me for magic

How to Ask for Programming Help
July 31, 2023
5 Minute Read
Programming,
Advice

Let me start out by saying that I love helping people with programming problems. Giving others a hand as they learn about programming can be both fun and emotionally rewarding. That said, there are definitely a number of factors that can affect how easy it is to help someone with a problem. Here’s some advice that can help improve the quality of your questions and the efficiency of the help you receive.


Try Something First

There’s a whole domain name dedicated to this by now. In short, if you’re asking for help, you should be asking for help, not a solution. Most people are glad to offer advice, but they’re not there to do your job (or hobby) for you. If you have a question, try to figure out what you can on your own first. It’s fine if you don’t manage to make any headway – at the very least, it’ll help the person down the line to rule out what won’t work for you.

If whatever you’re having problems with has documentation (e.g., man pages), try to find your answer there – you might not succeed, but you might be surprised at how many answers are sitting there in plain sight.

Try and see if your question has been answered before. Google searches, FAQs, etc. can all help in this regard.


Narrow Down the Problem

To make it easier for others to assist you, narrow down the problem you need help with. Avoid overwhelming people with extensive code or vague questions. Instead, try to create a concise and focused version of the issue you're encountering. Here are good and bad examples of how to narrow down a problem:

Bad Example:

I need help with my Java program.

Good Example:

Hello, I'm working on a Java program that's meant to read a text file containing a list of students and their grades, then calculate the average grade. However, when I try to run the program, I encounter an issue where the grades are not being read correctly from the file. The file format is as follows:

John Doe, 90
Jane Smith, 85
Bob Johnson, 78

I believe the problem lies in my readFile method, which I've included below:

public List<Student> readFile(String filePath) {
   // Code for reading the file and parsing the data goes here
}

Can you help me identify the issue in my code and suggest a fix?


Provide Enough Detail

Vague requests like "My code isn't working. Can you help?" make it challenging for others to assist you effectively. Instead, be specific and include relevant information. Here's a good and a bad example to illustrate the point:

Poorly Described Problem:

"Hey, my code isn't working. Can you help?"

Well Described Problem:

"Hello, I'm trying to implement a function that calculates the factorial of a given positive integer in Python. I've written the following code, but I keep getting an error: 'TypeError: 'int' object is not iterable.' Here's the code snippet I'm using"

def factorial(n):
   if n == 0:
       return 1
   else:
       return n * factorial(n - 1)

I've tested the function with some test cases, and it always fails with this error. Can you help me understand what's going wrong and how I can fix it?"


Don’t Be Lazy

If you’re asking for help, you’re asking for someone else to use their own time working on someone else’s problem. Don’t waste their time for silly reasons: check your question for typos, make sure any links you post work, and try to format things reasonably nicely if you can. If you’re asking a question somewhere that doesn’t have built-in facilities for sharing code, use a service like Pastebin.com to provide your code sample (and turn on the proper syntax highlighting).


Things to Do Before Asking for Help:

Before seeking help from the community, take some steps to enhance the effectiveness of your request. Following these guidelines can lead to better responses and a smoother problem-solving process:

  1. Attempt to solve the problem yourself: Put in a reasonable effort to understand the issue and find potential solutions on your own.

  2. Search for existing solutions: Look up similar problems and their solutions online. It's possible that someone else has encountered the same issue before.

  3. Check the documentation: If you're using a library or framework, consult the official documentation to see if it addresses your problem.

  4. Include a concise code snippet: Provide a minimal code example that reproduces the issue. This makes it easier for others to understand and pinpoint the problem.

  5. Include the exact error message: When dealing with errors, include the full error message along with relevant stack traces. This provides valuable information for debugging.

  6. Describe your expected outcome: Clearly state what you expect the code to do and how the actual behavior differs from your expectations.

  7. Provide relevant context: Explain the purpose of the code and any external dependencies that might be affecting it.

  8. Format your question neatly: Use proper formatting, grammar, and spelling to make your question easy to read and understand.

  9. Use a code-sharing service: If the platform you're using doesn't support code formatting, share your code on a service like Pastebin and provide the link.

  10. Be patient and polite: Remember that people are volunteering their time to help you. Be patient, polite, and grateful for their assistance.


Be Patient

Unless you’re paying someone for their time, you’re not entitled to their help. There are plenty of people willing to answer questions out there, but they don’t tend to like being badgered. Once you’ve stated your problem or question somewhere, give it some time. Generally, people who are willing to help will do so when they’re able. It’s fine to ask a question in other places if you don’t get a response from the first place where you ask (but if you do get a response somewhere else, be polite and let the other places you asked know – and even better, include the answer if possible).


If you liked this post, you might also like the older (and slightly more abrasive) How to Ask Questions the Smart Way, by Eric S. Raymond.

Enjoyed Reading?

Feel free to reach out and connect with me on

!

    © , all rights reserved.