21

Why are "best practice" questions so derided here, when "pattern" questions are not?

According to Wikipedia:

Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.

I've read some of the articles discussing why "best practice" questions are thought to be often/usually/inevitably mushy and unhelpful. I even agree with much of the reasoning. But I've also seen "best practice" questions that seem appropriate and on-topic. Even they face rapid down-voting for hold or close, and chiding in the comments.

My confusion is that even though patterns are, by definition, "best practices," Programmers is awash is pattern questions--and they seem warmly welcomed. Even when they are vague or novice--some on the order of "please boil the ocean for me and give me the best pattern name for this situation that I have apparently never even Googled"--they don't seem to suffer rapid dismissal, down-voting or chiding. They are graciously entertained and answered.

So what gives? Is "the right pattern" just an a community-enforced euphemism? Or is there a meaningful distinction being made?

9
  • 3
    Meta-postscript. As I was posting this, I was required to add a tag. The only one that seemed appropriate, discussion, is defined as: "designed to solicit opinions or best-practices ..." Yikes! Commented Oct 30, 2014 at 16:44
  • 3
    On Meta, discussions are apropos.
    – user53019
    Commented Oct 30, 2014 at 16:48
  • So best practices about the site are relevant, but best practices on the site are not? Commented Oct 30, 2014 at 16:49
  • 1
    Meta != Main (aka Programmers). Meta is for asking about why something doesn't work on Main, which can naturally lead to a discussion. The rules are intentionally different and are even reflected in this site's name of "Meta." Meta is to deal with meta things about Main.
    – user53019
    Commented Oct 30, 2014 at 16:51
  • @GlenH7 I wasn't arguing about "discussion" in main vs meta. I was pointing out that one of the tags for meta is explicitly described as being about "best practices." I wouldn't want an "empty resonant cavity" on meta any more than on main. Commented Oct 30, 2014 at 17:13
  • 1
    FTFY. :-) I don't see any mention of best practice in there (anymore).
    – user53019
    Commented Oct 30, 2014 at 17:20
  • Well if we hate "best practices" that much, I'd call that progress! At least we'll be consistent! Commented Oct 30, 2014 at 17:26
  • The "problem" is the word "best," which has a subjective tone. Patterns has an objective tone. It, and "best practices" mean basically the same thing, but they "sound" different on SE.
    – Tom Au
    Commented Nov 10, 2014 at 16:18

5 Answers 5

23

From Why is asking a question on "best practice" a bad thing?

While you may be an exemplary, clear-thinking, individual, who uses the term 'best practice' in a constructive manner, you have been preceded by a giant procession of zombies who use it as the antithesis of thought. Instead of understanding the important specifics of their situation and looking for an appropriate solution, all they want is to spot a herd in the distance and go trotting off after it. Thus, the term 'best practice' has been rendered an extremely strong signal of a empty resonant cavity in the place where a brain should be, and questions that mention the phrase get closed.

My question to the OP is often this: what do you mean by best? The answer is often, "What programmers generally accept as the correct solution," which is a tautology, or "which one do programmers choose most often," which suggests popularity as a valid metric for choosing a technology.

My response is often "The best way is the one that most effectively achieves your software's functional and non-functional requirements."

Software design patterns are a different animal. These are well-accepted solutions to well-understood problems, and serve as a vocabulary for developers designing their programs. They are considered best practices, not because they are "correct" or most popular, but because they are proven solutions in the problem domains they are solving.

When a person asks "what is the best design pattern for this particular problem," they are engaging in a pattern-matching exercise, not cargo-cult programming.

20
  • 3
    That doesn't answer the question. It is not "why are best practice questions a bad thing?" It's "Why are pattern questions not equally bad?" I could recapitulate the above text with s/best practice/pattern/g and it would still be true. Commented Oct 30, 2014 at 16:52
  • 1
    See my update.. Commented Oct 30, 2014 at 16:53
  • Your outcome-oriented response is admirable. Still not sure why "best practices for X?" is a terrible question and empty resonant cavity whilst "right pattern for X?" is not. A pattern is a software design best practice. Commented Oct 30, 2014 at 17:00
  • 1
    Okay, so you're arguing that patterns are the TRIZ of software design. The patterns against which we match. Fair point. But patterns too can be the subject of cargo-cult adoption and orthodoxy. And in fact, they often are. Commented Oct 30, 2014 at 17:03
  • No argument there. Commented Oct 30, 2014 at 17:10
  • 3
    FWIW first thing I do is try to see how question would look like with "best practice" words removed. If it keeps making sense, fine. But sometimes it happens that this makes it start rendering a "signal of a empty resonant cavity"...
    – gnat
    Commented Oct 30, 2014 at 17:47
  • 1
    @JonathanEunice a question asking "which pattern is best" is no more appropriate than a question "which methodology is best".
    – jwenting
    Commented Nov 7, 2014 at 9:51
  • Best practices are not a bad thing, in and of themselves. Asking what the best practice is for a given case is asking for a generic solution to a particular case. I love the phrase "antithesis of thought". Commented Nov 7, 2014 at 11:00
  • @jwenting Exactly! "Which X is best for Y?" is the same question, for X ∈ {pattern, approach, practice, methodology, technique, ...} Yet we accept X = pattern questions quite happily, yet categorically abhor X = practice questions. Commented Nov 7, 2014 at 14:50
  • 1
    I disagree. The very act of approaching programming as an act of pattern matching is deserving of all the criticism you raise against best practices. The problem is that a tool ceases to be useful when it is put on a pedestal. This problem is universal, and therefore software design patterns are also affected by it.
    – back2dos
    Commented Nov 11, 2014 at 9:11
  • 1
    Not relevant to the answer as such..Can you explain how is this tautology? I did not understand it. //"What programmers generally accept as the correct solution," //
    – Krishnan
    Commented Nov 11, 2014 at 12:06
  • 2
    @Krishnan: When I ask "What do you mean by 'best'," the answer I often get is "which one is correct," or "which one do most programmers think is correct," which is the same question as "which one is best." Commented Nov 11, 2014 at 15:20
  • "which one do most programmers think is correct" :)
    – gnat
    Commented Nov 12, 2014 at 13:18
  • "[Software design patterns] are well-accepted solutions to well-understood problems". You know that's the exact same tautology you're complaining about, right? Commented May 23, 2015 at 8:29
  • @RichardMarr: chat.stackexchange.com/transcript/21?m=21642833#21642833 Commented May 23, 2015 at 13:57
9

A "best practice" is a technique or process that developers agree is the correct way to do something. However, the question is rather loaded. What makes it "best?" Why is one technique better than another, and does it depend on context? Of course what is "best" in one instance of a problem might not be best in another. In other words, why not just ask "how do I solve this problem?" instead of "what cookie-cutter technique can I apply here?" A best practice is, in essence, a popularity contest anyway. That works well for random "reality" TV shows, not so well for developing good software.

Design patterns are objective. I can draw a strategy pattern on a whiteboard and we can agree that it is, in fact, the strategy pattern.

The difference here is that while we can clearly define a design pattern, we do not necessarily agree that it is the right tool for a particular job or is the best way to approach a problem.

Of course, "pattern shopping" problems tend to exhibit similar problems to "best practice shopping" problems. The key here is "shopping." Someone heard of a buzzword and thinks it will solve a problem, so they ask a question for "I need a recommendation on which widget is the best one." Whether talking about best practices or design patterns, the correct question is to ask how to solve the problem at hand, and to be open to all constructive suggestions.

6
  • 2
    "a technique or process that developers agree is the correct way to do something" ... "It is very opinionated". And there, with that conflict, lies the problem.
    – pdr
    Commented Oct 31, 2014 at 17:21
  • "I can draw a strategy pattern on a whiteboard and we can agree that it is, in fact, the strategy pattern." Good. Now let's do MVC. ;P
    – yannis Mod
    Commented Oct 31, 2014 at 21:38
  • 1
    @YannisRizos of course you have to pick the one pattern that has at least 4,782,947 different implementations, each with their own slight differences. However, it is possible to draw a "generic" MVC showing the separation of concerns and direction of messages and events.
    – user22815
    Commented Oct 31, 2014 at 22:14
  • 1
    which pattern to employ is often subjective. And definitely the stereotypical "which is the best pattern" question is bad.
    – jwenting
    Commented Nov 7, 2014 at 9:51
  • 2
    Best practices are not opinionated. People are. The effectiveness of any practice can be measured, if you are clear about what effect you are after. It is the "best practice to achieve X". Different companies strive for different effects, therefore different practices are respectively the best ones for them. But there are practices that demonstrably do what they are supposed to. There is nothing subjective about that.
    – back2dos
    Commented Nov 11, 2014 at 9:25
  • Good discussion here. We can probably say "best practices" transposes to "patterns", and "bad practices" transpose to "anti-patterns".
    – Rob Grant
    Commented Nov 12, 2014 at 6:38
6

Best practice questions themselves aren't that bad, but too often they're about something that has no consensus best practice. At that point, they quickly become "what do you think about X?" questions, which tend to devolve into argument and flame war.

Pattern questions tend to be a bit worse actual questions (more of the aforementioned cargo cult) though they at least have single answers.

3
  • more often than not, "which is the best pattern" question has multiple or no answers, just as "what's best practice" questions...
    – jwenting
    Commented Nov 7, 2014 at 9:52
  • 2
    ...which makes it "primarily opinion based" because there are multiple answers, all of which are equally valid ("has no consensus best practice")
    – user22815
    Commented Nov 7, 2014 at 19:16
  • The OP addresses this already. I was going to quote him, but it is in multiple places in the question. I'm not sure what this answer adds to that.
    – Rob Grant
    Commented Nov 12, 2014 at 6:39
6

Guilt by association; the term is often misunderstood and therefore misused. Questions like "spaces vs tabs", "Java vs Ruby" and "should this method be private?" has nothing to do with "Best Practices". There are however practices which almost all of the best developers agree upon, this set of practices is what the term "Best Practices" refers to.

Stack overflow even states:

We expect answers to be supported by facts, references, or expertise

Now, doesn't that sound a lot like the definition of "best practices"? A practice which is not supported by facts, references or expertise can't be considered a "best practice".

Lastly note that "Best Practices" is a misnomer; "Best Practices" are not the best ways to solve problems, they are the practices used by the best in the field. So when consultants sell "Best Practices" all they do is implement practices used by top firms.

-1

A best practice can be applied beyond programming and certainly is more generic than a design pattern, which is very programming specific within the stack exchange network.

UX has best practices, info-sec has best practices, and these are some areas where.. you really shouldn't deviate too much. For example when information security is concerned, its strongly encouraged to not roll your own security. Salting a password before hashing it is a best practice, not a design pattern. And just because you may not understand the benefits of doing so does not mean that you should deviate from it, and getting creative with it is not encouraged.

For UX, designing with the goal of being intuitive means following some best practices. There are infinite ways to layout a website/form, but its not a good thing to have to educate the user how to use it if you can avoid that. Ideally it is an intuitive experience, which is where best practices come into play.

I'm not familiar with why some programmers associate the phrase negatively, you'll have to refer to their answers. However I do not share that viewpoint. And downvoting for usage of the phrase is downright childish.

You must log in to answer this question.

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