DEV Community

Cover image for The Art Of Asking Good Questions

The Art Of Asking Good Questions

Vaarun Sinha on February 03, 2022

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. Mos...
Collapse
 
ingosteinke profile image
Ingo Steinke, web developer • 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?