How To Ask Better Questions
Learn from yesterday, live for today, hope for tomorrow. The important thing is to never stop questioning.
– Albert Einstein
As a programmer, you are going to hit a lot of problems, you need to constantly ask questions. You will get stucked at a problem for days, sometimes up to weeks! And you won't be able to progress if you don't solve it. I mean, even if you do, how much did you really learn spending all those time debugging just to find out that all you're lacking is a semi-colon? It's just not effecient.
The key is to ask questions. Ask the right questions.
It's crucial for your success.
However, often times in the self-taught journey, there's no teacher. You embarked on this journey on your own. There's no "friends" to journey with you. Yes, you have mentors along the way, but no one's obligated to answer every question that you have. (Shameless plug: Check out our weekly mentor-led learning groups! Where you learn full-stack web development alongside a bunch of self-taught enthusiasts guided by a mentor)
Whether you're asking questions on Stackoverflow, Reddit, in your team or at The Hacker Collective, asking good questions is essential. People that ask good questions are more effective because they get better answers more quickly and more often. They’re also taken more seriously and get more respect, which matters if you care about your growth & career.
IMPORTANCE OF ASKING QUESTIONS
- You discover something new.
Regardless of whether or not they’re related to something within the scope of your problem, you increase your chances of discovering something new. This may not guarantee to lead you in the right or optimal direction but it’s possible that, in the future, it will benefit you in some way.
2. You resolve issues and connect the dots.
You can also resolve issues by asking questions that seem to have nothing to do with the topic at hand. If two people are arguing about something, it might help to know more about them and where they’re coming from before the issue can be resolved.
3. Asking questions is likely to jog your memory.
You might remember something that helped you in the past that you had forgotten. Or you might remember someone else who had a similar experience and how they dealt with it.
So it's clear that there are some good benefits from asking questions. However, most people are absolutely terrible at asking questions, but the good thing is that you can follow a few simple steps to be great at it.
5 Simple Steps To Asking Better Coding Questions
1. Check for typos.
- Nobody wants to look for your typos.
- Go back to a point where your code worked and redo from there, make sure that your code continues to work each step of the way. If you get to a point where your code doesn’t work, go back to the last point in time where it worked and double-check for typos.
- If you’re coding along a specific lesson and the code is provided, check the provided code and see if it works. If the provided code works but yours doesn’t, then you have a typo. Now that you are sure that you have a typo, it’s your job to find it. Go back methodically and figure out where you messed up. Do not waste someone else’s time and ask them to do something that you should do yourself.
2. Provide the specific code that illustrates the problem
- Isolate just the part that is broken and share that.
- Make sure that the code doesn’t change by the time someone looks at it. That means you should create a separate copy of your code just for your question. If you change the code by the time someone looks at it, your question is not just a bad question, it is inaccurate, which is worse than bad.
- That’s because everything might have changed, but there’s no way the person answering will know about it. Do not punish people that want to help you.
The rubber duck debugging method is as follows:
1. Beg, borrow, steal, buy, fabricate or otherwise obtain a rubber duck (bathtub variety).
2. Place rubber duck on desk and inform it you are just going to go over some code with it, if that’s all right.
3. Explain to the duck what your code is supposed to do, and then go into detail and explain your code line by line.
4. At some point you will tell the duck what you are doing next and then realise that that is not in fact what you are actually doing. The duck will sit there serenely, happy in the knowledge that it has helped you on your way.
Simply put. Understand each line of code that you're writing. It helps with your learning journey when you can break down code line by line and explain what they're doing. Go through line-by-line and figure out what each line does. Take notes, think about things that might be confusing. Let them sink in.
Check out more about it rubber-ducking here.
4. Use a debugger
A debugger is a computer program used to test and debug other programs.
A debugger is a very powerful tool for helping diagnose problems with programs. And debuggers are available for all practical programming languages. Therefore being able to use a debugger is considered a basic skill of any professional or enthusiast programmer. And using a debugger yourself is considered basic work you should do yourself before asking others for help. As this site is for professional and enthusiast programmers, and not a helpdesk or mentoring site, if you have a question about a problem with a specific program, but have not used a debugger, your question is very likely to be closed and downvoted. If you persist with questions like that, you will eventually be blocked from posting more.
If you don’t know how to use a debugger or don’t know what it is, watch the video below.
5. If you need to show code, make sure you find a way for the answerer to look at, access and edit your code easily.
Even though the person you’re asking is much better than you, he/she probably can’t get to the correct code without debugging.
For frontend / static questions, you can use online code editors like Codepen to create your test case easily.
If you really want answers to your coding questions, make the journey easier for your mentor to access, edit and debug your code.
Do not send a picture of your code from your potato camera.
Do not send a picture of your code that requires your mentor to tilt his/her head sideways just to view your image because it's rotated.
Chances are, they're not even going to try.
All in all
Good questions save time. Bad questions waste time.
Bad questions create unnecessary & inefficient conversations, which create a lot of frustration and conflict. People that ask bad questions get annoyed because they can’t get help, and people that are trying to help get irritated because most bad questions are just impossible to solve.