From Confusion to Clarity: How to Ask Better Questions When Learning To Code
Regardless of the programming language you’re learning, asking the right questions is essential to getting the right answers. It’s part of the learning process which allows you to gain new perspectives and insights on a problem or issue, which can lead to better understanding and more efficient problem-solving.
Additionally, by asking good questions, you will be able to identify misconceptions or misunderstandings that may be causing confusion, and this can lead to better understanding of the problem or issue. Knowing how to ask better questions can also save time. Instead of spending hours or days trying to figure out a solution, you can ask someone who may already know the answer or have experience with a similar problem.
# Tip 1: Start with “Why?”
Starting with the reason behind a question can lead to more specific and useful answers because it helps to clarify the context and purpose of the question. By understanding the reason for asking a question, the Senior engineer can provide a more targeted and relevant response.
For example, if a Junior dev (or just someone learning to code) is trying to understand how to use a certain function in their code, but they don’t understand why it’s useful, they might not know how to properly apply it in their program. But if they understand the reason behind the function, they can better understand how to use it in their specific coding context.
Starting with “why?” can also help identify any underlying misconceptions or misunderstandings that may be causing confusion. When the reason behind a question is understood, it may become apparent that the question itself is not well-formed or that a different question would be more appropriate.
Let’s look at how we can improve a couple of bad question by starting with “why?” and adding the reason why we’re asking.
Question 2: What’s wrong with my code? Improved version: I’m trying to implement a feature that allows users to upload images, but the images are not appearing on the website, what could be causing this problem?
Question 3: How can I make my code run faster? Improved version: I’m trying to sort the array of numbers, but the code works very slow when the number of elements in the array is high. How can I improve my sorting algorithm?
As you can see in these examples, starting with the reason behind a question provides more context and purpose, allowing the person answering to provide a more targeted and relevant response.
Bonus tip: you can go the extra mile and ask a few more “why” questions to get down to the root cause (the original reason behind the question).
# Tip 2: Be Specific
Being specific in your questions can lead to more accurate and helpful answers because it helps to clearly define the problem or issue that needs to be addressed. When a question is specific, it is easier to understand the exact information or assistance that is being requested, which in turn allows them to provide a more accurate and helpful response.
For example, if a coder is trying to debug a piece of code that is not working as expected, a specific question like “Why is the function
submitForm not sending the data to the server?” is more likely to result in a helpful answer than a more general question like “Why is my code not working?”.
Specific questions also helps to narrow down the scope, which can make it easier to find a solution. A specific question like “How can I change the background color of a login button in my iOS app?” is more likely to result in a helpful answer than a general question like “How can improve the design of my app?”.
Another example would be a developer who’s trying to understand how to use a specific API.
Instead of asking “How do I use this API?”, they could ask “I’m building a weather app and I want to use OpenWeather API to retrieve the current temperature. How can I use the API to retrieve the temperature and display it in my app?”
# Tip 3: Do Your Research
Researching a question before asking can lead to better understanding and more efficient problem-solving for a few reasons:
- Clarify the problem or issue. By researching a question before asking, you may be able to gain a better understanding of the problem or issue at hand, which can make it easier to ask a clear and specific question.
- Identify potential solutions to be more efficient in problem-solving, as you will have a better idea of what solutions are available.
- Understand the context so that you have a few ideas why the problem or issue is happening and what the most appropriate solution might be.
- A beginner wants to understand how to use the
- A student is trying to optimize the performance of their code in a React application. Instead of asking “can someone help me improve the performance of my React app”, they research on the internet and find suggestions to use
shouldComponentUpdate()lifecycle method to limit re-rendering of components, using the
React.memo()and Higher Order Components, and using the
- You’re trying to implement a feature that allows users to upload file to the website, but you have no idea where to start. Instead of immediately asking someone for help, you start searching the internet and arrive to a Stack Overflow solution that suggests using the HTML tag
<input type="file" />
Even if your research doesn’t help you solve the problem immediately, you’ll be in a better position to ask a specific question that starts with “why?”.
# Tip 4: Active Listening
Active listening is the process of actively paying attention to and engaging with the speaker or source of information. When reading programming books or watching educational videos, practicing active listening can help you to better understand and retain the information being presented.
Here are a few ways to practice active listening when reading books or watching educational videos:
- Focus your attention. Eliminate distractions and focus your attention on the book or video. Avoid multitasking or allowing your mind to wander.
- Engage with the material. Ask yourself questions as you read or watch, and actively think about how the information relates to your own experiences and knowledge.
- Take notes. This will help you to retain the information and refer back to it later.
- Summarize the key points. After reading or watching, try to summarize the key points in your own words. This will help you to understand and retain the information better.
- Reflect on the material. Reflect on the material after reading or watching. Think about how it relates to your own experiences and knowledge, and how you can apply it to your own coding journey.
By practicing active listening when reading books or watching educational videos, you will be able to better understand and retain the information presented. It will also help you to relate the information to your own way.
# Tip 5: The Rubber Duck Method
The Rubber Duck Method or the Rubber Duck Debugging theory is a technique where you explain the problem or issue you are facing to a rubber duck (or any other inanimate object) as if it were a colleague.
The process of explaining the problem in detail, often including the code and the expected outcome, helps to clarify the problem and can lead to identifying the source of the issue.
- Identify the problem. Clearly define the problem or issue you are facing in your code. Be specific and detailed about what is not working and what you expect to happen.
- Explain it to the rubber duck. Take a rubber duck or any other inanimate object and explain the problem to it as if it were a colleague. Be sure to include the code and the expected outcome. This process of explaining the problem in detail can help to clarify the problem and make it easier to identify the source of the issue.
- Check your assumptions. As you explain the problem to the rubber duck, check your assumptions and make sure you understand the problem and the code. This can help you to identify any misconceptions or misunderstandings that may be causing confusion.
- Look for patterns. As you explain the problem, look for patterns in the code that may be contributing to the issue. This can help you to identify the source of the problem and to find a solution.
- Test your solution. Once you have identified the problem and a potential solution, test it to see if it works.
By using the Rubber Duck Debugging theory, you will be able to identify the problem in a clear and concise way, which will help you to find a solution more efficiently. It will help you to understand the code better and to identify any misconceptions or misunderstandings that may be causing confusion.
# Thank you!
Let me thank you on behalf of every Senior engineer you’ll meet in your life. By learning how to ask better question you’ll save yourself (and everyone around you) so much time that your progress in becoming a better software engineer will skyrocket.
By applying these tips, you will be able to ask better questions when learning to code, you’ll find solutions to your problems more efficiently and gain a better understanding of the code you write.
Remember, don’t be afraid to ask for help, practice active listening and keep in mind that research is key to success!