头图

How to ask a high-quality question?

唯一丶
中文
Cover image credit: Pexels

foreword

The moment you see the title, you may be thinking, "What kind of question is a good question?", and thinking about it, there are more or less a dozen new questions every day (except days off), and this There are a lot of "quality" issues in there.

If you have read the bookThe Wisdom of Asking, then you should know how to ask a question. This article is also a derivative supplement to this book.

Below, I will take you to ask a good question from my perspective.

Do you really need to ask this question?

Before asking a question, you should use search engines such as Google, Baidu, Bing, etc. to try to find the answer, because most of the time, the problems you can encounter, others may have encountered, and then follow the solutions. deal with it, the problem may be solved.

For example: How does Vue routing work? - SegmentFault

Problems that can generally be described may be easier to retrieve. Maybe you spend half an hour searching and your problem has been solved.

And if you choose to ask a question directly, there is a high probability that it will not be solved within 30 minutes.

How to retrieve the problem is relatively easy most of the time, but in some special cases, it becomes troublesome. For example, if we make an error when running the command, it may print out an extremely lengthy error message, and it is basically in English. , it is crucial to extract useful information from it.

For example, like the bunch of error messages below .

 D:\workplace\newcodebdc\back> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: vue-antd-jeecg@2.0.0
npm ERR! Found: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR! webpack@"^4.0.0" from @vue/cli-plugin-babel@3.12.1
npm ERR! node_modules/@vue/cli-plugin-babel
npm ERR! dev @vue/cli-plugin-babel@"^3.3.0" from the root project
npm ERR! webpack@"^4.0.0" from @vue/cli-plugin-eslint@3.12.1
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"^3.3.0" from the root project
npm ERR! 3 more (@vue/cli-service, less-loader, sass-loader)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! vue-loader@"^15.7.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@5.73.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^5.0.0" from css-loader@6.7.1
npm ERR! node_modules/css-loader
npm ERR! peer css-loader@"*" from vue-loader@15.10.0
npm ERR! node_modules/vue-loader
npm ERR! vue-loader@"^15.7.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\MaxThunder\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

At this time, we only need to copy this part of the error information, translate it first, and try to understand why it is wrong. If you can't understand it, go to the search engine to search. In most cases, you can get the answer.

When an error occurs, we should first look for a keyword in the error message Error , most of the time, when this keyword appears, it will print out the specific error, some of which are also A wrong CODE will be printed out, such as the error reported by MySQL. You can follow this CODE and add the software name, and you may be able to retrieve it.

As above, it is full of ERR , there are a lot of mistakes, you can't tell at a glance, if you copy the translation, you can probably know that it is "xxx dependencies cannot be resolved", and the following There is also a fix(修复) method, which allows you to try adding --force or --legacy-peer-deps after the command to retry, maybe the problem will be solved after you execute it, you There is no longer a need to ask a question.

submit questions

appropriate title

Most communities are displayed in the list in the form of titles. For example, Sifu will also display tags in the list. The answerer is not a robot. Most of the time, the answerer will not open all the posts for viewing. A suitable title will allow the answerer to judge whether the question is within the scope of their own solution, so as to open it.

bad example

good example

High-quality problem description

The last important thing you need to do before your question is resolved is to let the respondent know what you are asking, otherwise it will be difficult for others to answer you.

Just like Sifu's question template:

  • What problem are you having?
  • What are your expectations?
  • What is your environment (software version running, operating system)?
  • What kind of work have you done?
  • The code in question

According to the above rules, describe your problem so that the answerer can more clearly know what problem you are encountering. In addition, you may also need to provide some additional information to help the answerer help you faster Solving the problem, after all, saves time for the respondent and saves time for yourself.

Learning to use Markdown syntax won't take you much time, ten minutes at most, but it will benefit you for a lifetime.

1. Don't use pictures to upload code . The communities currently discussing basically support Markdown syntax. It takes a little time to learn how to paste the code, so that the answerer can also directly copy the code to their own environment to run and reproduce quickly. /Locate the problem.

Use three ` symbols (the upper left corner of the keyboard, below ESC , in front of the number 1 , input in English), followed by the language type, and finally start a new line and write three ` to form a code block.

```js
alert('Hello')
```

The final result will be displayed as follows.

 alert('Hello')

2. Provide as much useful information as possible

In database-related questions, it is especially common. When most people ask questions, they directly send screenshots of data and query statements written by themselves.

Because SQL itself is abstract, especially complex SQL, must be tested to meet expectations.

This greatly reduces the interest of the respondents. Although the OCR technology is powerful enough now, it may be recognized, but sometimes it needs to be corrected. Moreover, most of these problems are dealing with data. The important thing is Data, you don't provide anything, others can only watch it from a distance.

For the question method of the SQL class, you should attach the table creation statement, the data filling statement, and the query statement written by yourself.
For the table build statement, you can use show create table 表名称; to get it.

For data filling statements, take MySQL as an example, you can use mysqldump this tool to export, however this may be a little more complicated. But now some SQL management tools provide graphical export as insert statement.

And all you have to do is take a few minutes of your time.

for example:

 # 建表语句
CREATE TABLE IF NOT EXISTS `myTable` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `name` varchar(255) default NULL,
  `score` mediumint default NULL,
  `sex` mediumint default NULL,
  PRIMARY KEY (`id`)
) AUTO_INCREMENT=1;

# 数据插入语句
INSERT INTO `myTable` (`name`,`score`,`sex`)
VALUES
  ("Abdul Stanley",143,2),
  ("Chaney Pickett",62,2),
  ("Keelie Lindsey",99,2),
  ("Rae Hartman",146,2),
  ("Nevada Ward",72,1);

After others get it, they can easily process it in their own environment. You may also need to provide SQL_MODE information.

In addition, there is the MySQL version you are running.

Of course, sometimes our data may contain sensitive information, please remember to release it after desensitization.

You can also use some data construction tools to build data with similar structure to yours, for example: generatedata

image.png

Or: mockaroo

image.png

Reject XY questions

The meaning of the XY Problem is as follows:

1) Someone wants to solve problem X
2) He feels that Y may be the solution to X's problem
3) But he doesn't know what Y should do
4) So he went to ask others what Y should do?

In short, instead of asking how to solve problem X, ask how solution Y should be implemented and operated. Hence:

1) Enthusiastic people help and tell this person what Y should do, but everyone thinks Y's scheme is a bit weird.
2) After a lot of discussion and a lot of wasted time, enthusiasts finally figured out what the original question X was all about.
3) So everyone found that Y is not a suitable solution to solve X at all.

The biggest serious problem of XY Problem is: waste a lot of time and energy of others in a fundamentally wrong direction!

give 🌰

Q) How can I get the last 3 characters of a string with Shell?
A1) If the variable for this character is $foo, you can echo ${foo:-3} like this
A2) Why do you want to take the last 3 digits? What do you want to do?
Q) Actually, I just want to get the extension of the file
A1) Damn, it turns out that you want to do this, so my method is wrong, the file extension is not guaranteed to have 3 digits.
A1) If your file must have an extension, you can do it like this: echo ${foo##*.}

help answerer

When asking questions, you can think more about the respondent, such as through some online services, so that the respondent does not need to operate on the local environment.

For example, for the database problem mentioned above, we can use db-fiddle to create an online MySQL operating environment. After filling in, click Run to confirm OK, and then click Save will A unique link address is generated for you. Now when others open this link, they can edit the operation directly on it, which is much more convenient.

image.png

In addition, like the front end can also use

These two are foreign services, which may be difficult to open. You can also choose domestic ones:

If your question is more complex, you might also consider providing a "Minimal reproducible example" to submit to the Git service for answerers. (☹️ I don't think it's usually complicated to this extent)

Complications

There is also a problem, that is, the problem is small, but the code is a lot.

Common CSS problems in the modern front-end. Many times, the problem occurs in a project or a component, and even if you provide the code of this component, the answerer cannot reproduce the problem well. For example, your DOM may be is rendered from the data.

In this case, when asking a question, you should paste the rendered result + the least code that can be reproduced, so that it is easier to reproduce the problem.

Alternatively, you can use some browser extensions to save the page as a single HTML file and upload it to a login/registration-free web drive or Git.

For example SingleFile , this extension can save all the content of the web page as an HTML file, making it easier for the answerer to reproduce the question.

(Of course, you should also provide the original code as much as possible)

gildas-lormeau/SingleFile: Web Extension for Firefox/Chrome/MS Edge and CLI tool to save a faithful copy of an entire web page in a single HTML file

Playground or Sandbox

For some unpopular languages, the above tools may not be covered, but you can also try to search 语言 Playground , you can probably find some services that can be edited, run, and shared online, such Laravel playground .

maintain your problem

A lot of times, I see the same question in different communities, and no doubt it was asked by the same person.

Of course, there are more opportunities to solve problems in multiple places, but these questioners often rarely "maintain" their own problems.

Maintaining an issue is often more important than raising it.

1. Respond/supplement your questions in a timely manner . Some people may ask questions for the first time and miss something. Sometimes someone will remind you what information needs to be supplemented. Please deal with it in time. Like Si No, you will be notified by email by default.

2. Communicate with the answerer . If your question description is not so perfect, or the answerer's understanding bias leads to the wrong answer, you should communicate with the answerer in time instead of ignoring others.

This also allows other answerers to know the specific situation. For me personally, if a question is not maintained by the questioner himself, then even if I have a solution, I will not choose to answer it.

3. Don't repeat the question . When your question has passed for a few hours or a day or two and still no one has answered it, please don't try to repeat the question again, because it is very likely that no one else has seen it, but it is because of the previous reasons. overlay. Of course, it's also possible that your question is too esoteric to answer for you. You can also try inviting some people to answer.

4. Choose the appropriate answer . When your problem is solved, you should choose the answer of the person who helped you solve the problem and mark it as the answer. This can also be a good help for others to find the correct answer in time when they encounter this problem.

5. After finding the solution, you should attach it. If none of the answers can solve your problem, but you solved it yourself, you should also attach the answer.

6. Synchronous solution , as mentioned earlier, many people will ask the same question in N forums, and it is often possible that the answerer of one of the forums has solved the problem, while the other forums have not solved the problem. As the questioner, you should synchronize the correct answer to the place where you once asked the question, just as you asked the question in the first place, to facilitate the later.

what have you done?

In addition to the above, the premise of asking a question is that you should try to solve it as far as possible within your ability, such as searching through search engines, trying existing solutions, and writing corresponding codes. Perhaps in these processes, Your problem is solved.

ok 🌰

write at the end

  • The above arguments are only personal opinions. If there are any shortcomings or mistakes, please do not hesitate to let me know.
  • You can also click on the source link in the article for more details.
  • If the content of the article infringes your rights, please contact me to deal with it.

refer to

阅读 3.4k

开发中的一些奇技淫巧
记录收集一些开发中遇到的奇技淫巧和坑

友情链接

17.8k 声望
2.8k 粉丝
0 条评论

友情链接

17.8k 声望
2.8k 粉丝
宣传栏