Your code doesn’t work and you have no idea why.
Congratulations! Developer achievement unlocked!
Hitting a wall because of broken code with (seemingly) no solution in sight will happen at least once during your journey as a developer.
And that’s ok.
The idea of running into a problem that you cannot solve is not meant to scare you. In fact, I mean for it to be the exact opposite. Knowing how to troubleshoot, when and how to ask for help is a valuable skill as a developer.
Here’s a short guide on how to ask for help in a way that concisely moves you toward a solution.
When presenting your problem to ask for help, realize that someone outside of your codebase may not know what you are working with, which may make it difficult to offer solutions.
Some questions to ask yourself before presenting a problem include:
- What were you expecting to happen?
- What did happen?
- What have you already tried and what was the result then?
Include details like operating system, browser or framework if it is relevant. Anything that may help someone else have an idea of is going on. That way, they have a good understanding of where you are, what you are working and how to jump in to help.
If you can—please keep sensitive information in mind—share a snippet of your code. For someone trying to help, it is helpful to know exactly what code you are working with. With a code sample, they can quickly look for common gotchas like misspellings or syntax errors. They may also use your code to try and recreate the problem locally and test possible solutions.
Sharing full sections of code is ideal. If it a larger project, push your code to some place like Github and share the link to your repo. Mention which files, functions or lines of code you are currently having problems with.
For example, you may say that the math on your
howManyDaysUntilHalloween function is off in the
spooky.js file. This way, whoever is helping you can get right to the problem instead of searching your codebase and hoping they found the one they think you were referring too.
For smaller projects, sharing a single file or function is fine. If you can, attach the code as a text file or formatted as code. This way, the formatting remains intact and the code can easily be copy-pasted. If you are getting any specific error messages, you can share those as code snippets too.
Have you tried turning off and on again?
Why yes. Yes, I have.
Debugging, just like knowing when to ask for help is another key skill of being a developer. When you run into unexpected behavior, take a step back and spend a little bit off time trying possible solutions before asking for help.
If you are able to find a solution on your own, great! You can stop reading this guide and keep coding. Otherwise, you can share what you have tried and the results.
For example, if your code was working before, what was added recently that may be breaking it? What functionality were you trying to add?
Removing the most recent code additions—or temporarily commenting it out—may help you to see exactly where in the program it is breaking. Are you getting no output when there should be one? Or, are you getting an output but it’s not the result you were trying to achieve?
While you are debugging, make note of what you have tried, if it worked, kind of work, or didn’t work and share those with your code when you are asking for help. That way, your helper can skip over suggestions you have already tried and guide you in the right direction.
Thanks to your helper, your code is working now! Cool.
But, now that it is working…do you understand what went wrong in the first place? Or what the fix is actually doing?
Part of being a developer is learning from your mistakes. If you can, ask if your helper can explain what the problem was so that it can be avoided for future builds. They may be able to explain the why and why not’s behind a concept in a way that makes more sense in the context of your project. Consider asking if they have any resources they would recommend for further reading.
This is also a great time to take notes. Add comments to your code so that future you knows what each line of code is doing and why.
In summary, running into a problem you cannot solve is not the end of the world, even if it feels like it. By taking the time to analyze the problem, presenting it in detail with supporting code and expectations you can get the help you need in no time.
What advice would you give a fellow developer when they are stuck and are looking for help?
This post originally posted on my blog: https://shannoncrabill.com/blog/asking-for-help-as-a-developer