9

Questions containing the words:

  • What is the "best practice," or
  • What is the "right way," or
  • Which technique is "most popular," "most sensible," "most reasonable," "okay," "wise," "acceptable," "most stylish," etc.

are often received poorly here. Why is this?

How can I get a good answer to questions like this?

7

Questions that merely ask "What is the best way to do something" are not answerable. Because there are always several ways to solve a problem in computing, there is no "best" way; there is only the way that most effectively solves your specific problem, in whatever way you define "effective."

So instead of asking what is the best way, tell us what "best" means to you. Do you want it to be the fastest code? The least amount of code? The most flexible or modular code?

Don't respond with "I want it to be all of these things. I want it to be the 'best'." Design goals can often conflict: to get the fastest possible code, you sometimes have to sacrifice readability and maintainability. So tell us which characteristics are the most important to you. Tell us, for example, that you're willing to sacrifice readability for speed.

Don't respond with a tautology. "I want it to be the kind of code most software developers regard as industry standard" doesn't tell us anything more about what "best" means to you, unless you can point to an actual formal standard like an ISO standard that objectively defines "best" in your specific situation.

Further Reading
Why is asking a question on “best practice” a bad thing?

  • I like this issue, but not this guidance. Imagine if when your dad taught you to ride a bicycle the only thing he told you was things like, "don't fall down", "don't ride into a tree", "don't close your eyes". I mean it's all true but I think the kid's gonna die. – candied_orange Sep 25 '16 at 17:51
  • @CandiedOrange: The people to whom this is directed have already closed their eyes, ridden into a tree and fallen down. My answer is not about showing them how to ride a bike; it's about showing them how to avoid going over the cliff. – Robert Harvey Sep 26 '16 at 2:08
  • Side remark: It is best to avoid the word "best" at all costs when asking questions. I once almost had a question closed because I asked about a "best approximation", which is a mathematically well-defined concept when approximating functions by polynomials. A better choice of words would have been to ask for the "most accurate approximation" relative to a specific metric. – njuffa Sep 29 '16 at 4:38
  • @njuffa: The Mathematics community would not have made that error. Such errors can be avoided by hot-linking the term to a definition. – Robert Harvey Sep 29 '16 at 14:53
  • @Robert Harvey I didn't ask that question on Mathematics, but on SO :-) Hot-linking a definition certainly sounds like a feasible alternative in general, but does it work in a question title? I might have also tried putting a short definition in the very first sentence, I guess. But there seems to be a certain amount of knee-jerk reaction to the word "best", so I would still advise simply avoiding the word in favor more descriptive alternatives, where possible. – njuffa Sep 29 '16 at 15:14
  • @njuffa: Frankly, it doesn't sound like a Stack Overflow question. – Robert Harvey Sep 29 '16 at 16:07
  • @Robert Harvey Given the specific context and the particulars, it was appropriate to ask the question on SO, and it was ultimately well received, after being almost closed in the first couple of minutes. Taught me an important lesson about use of "best", though. – njuffa Sep 29 '16 at 16:11
  • 1
    @njuffa [shrug.] meta.stackexchange.com/a/142354 – Robert Harvey Sep 29 '16 at 16:12
3

A best practice is not a silver bullet.

"Doing X is the best way to get Y in situation Z" is how most respectable best practices read to me. Usually followed with a hedge: "Well it's better than W here anyway".

"X will always do what you want in every situation" is how most respectable advertisements read to me. No, these are not silver bullets no matter what the advertising department told you. :P

We aren't here to advertise or advocate X. If we do anything with X it's to understand how X might fit in a development process.

So if you want to ask a best practice question we need X, Y, and Z. Likely W as well.

Is agile better than waterfall?

This leaves out the situation and what you want out of it. Waterfall is alive and well in many circles. How could we possibly answer that?

Will agile let me communicate with my customers better than waterfall while I develop this scrapbooking website?

Yeah, I think it will. Your scrap booking customers likely won't want to read many specification documents. They will look at a mockup of the web site and quickly tell you that the red and yellow color scheme makes their head hurt.

A best practice question ideally should include:

  • The practice
  • The objective
  • The situation
  • The alternative practice

Include these and there might be an objective way to answer your question.

1

How do I ask a “Best Practices” question?

Best Practice can be defined as a method or process that is generally recognized to get better results.

Examples that occur to me might be:

  • In Python, prefer to use context managers when given the option.
  • Store text data in utf-8 format in most cases.
  • Avoid storing data in ad-hoc csv or tsv formats.

Businesses love to follow Best Practices because it demonstrates that they have done their due diligence on the matter, and determined the most superior way.

Ambitious managers and software engineers love them for much the same reason.

However, there are frequently competing solutions and methodologies that are mutually exclusive, and that reasonable and mature software engineers would disagree about which is best, leading to the following principle of Unix programming:

Rule of Diversity: Distrust all claims for “one true way”.

To return to the question, then, "How do I ask a “Best Practices” question?" this is something of a Schrödinger's Question.

I would think that it is difficult to know in advance that given a specific question whether or not there is a best practice without knowing what that best practice is. Perhaps this is an opportunity for a self Q&A if you have thoroughly researched the matter and have the answer prepared (and a thorough check determines the question to not be a duplicate).

How do you know you have a best practice, then?

I would suggest that, even before asking this question, you thoroughly research your options, and present what you think reasonable mature software engineers would agree is indisputable "best practice".

Remember, answers go in the answers, so after doing this prep work, you should have an ideal self-Q&A.

If the matter is determined to be truly a question of opinion, we will likely put the question on hold and give you a chance to salvage it - and if it does not have the problems with it fixed, we will delete it.

As an alternative to thorough research and to prevent avoidable closure of your question, you might raise the matter in Software Engineers chat for advice on asking it - as the people who would be likely to vote to close it would be there to either help you fix obvious problems or advise you not to ask if it's completely unfixable.

  • Your examples all leave out the essential question: Why? Especially the third one. The first two might be reasonable rules of thumb given suitable justifications, but the third one isn't; CSV and TSV are absolutely suitable ways to solve certain problems. Your first paragraph would read better as "...a method or process that is generally recognized to get better results in certain situations." (for some definition of "certain") – Robert Harvey Sep 25 '16 at 22:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .