DEV Community

Cover image for The Art Of Asking Good Questions
Vaarun Sinha
Vaarun Sinha

Posted on

The Art Of Asking Good Questions

As developers, the more code we write the more bugs we have to tackle sometimes we may have just missed a simple semicolon(;) or maybe a typo.

Most of the times someone already has encountered that problem, and asked on stack overflow so we continue the tradition and copy and paste the first code snippet we see on that stack overflow question into our code.

But there are sometimes where we encounter truly unique problems / weird errors where no stack overflow answer or google can help us.

So to solve this problem we ask other developers on public forums, mail groups, discord servers etc...

To make sure you get help quickly you should know how to ask a great question!

But before asking make sure that you have properly debugged the code, referred to other Similar stack overflow questions and have researched enough on the topic/problem that you have.

Here are DOs and DONTs of asking question:

DOs:

  • Have a good title that summarises the problem.
  • Keep the content short.
  • Create a live online environment on REPLIT or other similar online platforms.
  • Provide operating system, framework/language version and relevant code.
  • Copy and paste only the error value not the whole file system traceback.

DONTs:

Here is a sample question that uses the above principles.

Sample Question

Title: Why does 1 + 1 = 11 in python?
Tags: #python
Error: When I add 1 and 1 in this program it prints 11 rather than the expected result of 2.
Code:

num_1 = input("Enter number: ")
num_2 = input("Enter number: ")
print(num_1 + num_2)
Enter fullscreen mode Exit fullscreen mode

OS: Mac OS (M1 Chip)
Python version: 3.9.4
Live Environment To Run The Code:
https://replit.com/@vaarunSinha/Asking-Questions-Example#main.py

Thank You For taking time to read this question. Please help me out.

Conclusion

The above question is really good, but here's the one and only problem with this question, that if I had researched enough I would have got the answer that actually I was adding strings.

I could not find a better example that's why 😅

I hope from now you will ask great questions as a developer!

Happy Debugging

Top comments (13)

Collapse
 
ingosteinke profile image
Ingo Steinke • Edited

A good question can already lead to the right answer. Ask yourself, what is the actual problem, and how could others possibly reproduce the problem in a minimal example? What did you already try? StackOverflow, notorious for deleting questions that do not meet their standards, has a useful introduction: How do I ask a good question?.

A question with the title "Weird behaviour while adding two inputs.(Python)" could also be improved. Imagine there are 10 questions about different kinds of "weird behaviour" in Python, you could not tell them apart from their title. You would not even know if you can help and answer without reading the details. I might have written "1 + 1 = 11 in Python" (which is not a perfect title either).

But the question is a very good example of a beginner's problem that could occur in other languages like JavaScript, too. As a senior, I might say, this is not an error, but you are using the language in the wrong way. I might remember that I made the same mistake more than once in JavaScript. I might add a link to one of the many answers and articles that already treat this problem and help you understand data types and duck typing.

I might also advise you to use an editor that helps to avoid that kind of code in the first place, only to find out that ESLint does would not complain if all parts of a string concatenation are variables:

  const a = '1';
  const b = '1';
  const c = a + b; // no warning, still prints '11'

  const d = '1' + b; // warning: Unexpected string concatenation. (ESLint: prefer-template)
Enter fullscreen mode Exit fullscreen mode

Thanks for your post and and happy coding everyone!

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

Thank you let me edit the article!

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

Feedback is highly appreciated, if you find any problem/mistakes (which is unlikely) then please comment the problem and I will fix it.

Hope you learnt something valuable today.

Hope You Have A Nice Day Ahead!

Happy Coding!

Collapse
 
valeriavg profile image
Valeria

I agree that asking the right questions is essential to get the right answer 😃 Yet there's a difference between asking questions to strangers and communication within the team.
In the latter case it's better to ask an imperfect question rather than none 👍

Collapse
 
manification profile image
Ananya

I like how you structured this. It is an important skill to ask questions to get the right answer. Another thing that I would like to add is, it often helps to share what you have tried to find a solution, so that someone looking at it knows what not to try again, or if there is a gap in your understanding.
For above example: You can say that you tried setting values that return as expected.
num_1 = 1
num_2 = 1
result = num_1 + num_2 # result is 2.
So you know that the issue is probably with the input.

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

Thank You, Yeah I could have added this but since the above question is really simple I did not think it was necessary. 😁

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

What is your favourite question?

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

I don't know actually 😅, what's yours?

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

"Do you want this chocolate? I can't any more of it, I'm full up!"

That's a good one, absolutely in the top 10 🍫😆

Thread Thread
 
vaarun_sinha profile image
Vaarun Sinha

Yeah 😂

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

Thank you for this wonderful comment! Yes we should try to avoid asking Y here!

Collapse
 
simonpister profile image
SimonPister

In computer languages where the “1”s might be strings and the “+” operator performs string concatenation that’s why 1+1 =11 . Am I right ? wazifa to convince parents for love marriage

Collapse
 
vaarun_sinha profile image
Vaarun Sinha

That's correct, btw what is that weird link?