12

There is a somewhat frequent type of question around SE.SE that makes me scratch my head in confusion, sometimes - The "What's the best pattern for X" questions.

More often than not, the person who is asking those questions is a somewhat newbie developer, having its first contacts with a more advanced concept like patterns. Often, the developer in the question isn't concerned about the exact details of the problem he has to solve - he just want a pattern that can fix his barely specified problem and be done with it, more or less like some people love to copy-paste code from Stack Overflow without understanding what exactly is going on.

While design patterns are really helpful to understand software and to think about possible solutions, they are a relatively dangerous type of power tool for us developers and designers, more or less like a chainsaw - they are awesome to solve a few problems but can hurt you very badly if you don't know exactly what you're doing.

So, usually, when I see those questions asking for help to shop for a pattern for a problem they barely described, I usually leave a comment pointing them to the fact that patterns are not a buffet of solutions to pick from, and that they should understand their language and their problem better before hunting for patterns. Those questions still gather answers anyways, because reasons.

I'm starting to question myself is those questions aren't actively spreading misinformation about this really useful resource. While it is good that people search for the best solutions for their problems, "give-me-a-pattern" style of questions are just lazy, not far away from "give-me-da-code" questions from SO. Those questions normally show such a lack of understanding for the topic they end up being just garbage - the developer in question not only won't be able to implement those patterns properly (because he lacks the skill to understand how they work in the first place, which is not low) but will also leave a blighted question on the site that incentives that sort of lazy, low-quality, not-critical thinking that is hurting our profession badly nowadays.

Design Patterns aren't something one can just pick from a book and use to solve a problem, and they aren't something that can effectively be recommended using a shallow description of a problem as a basis. They are very important structural decisions that must be made by people that understand the full scope of the problem, not by us.

So, while I applaud the questions about implementing design patterns correctly, I suggest that we close those "Shopping-for-patterns" questions on sight. They are not helping us, really, nor the developers that ask them without knowing exactly where they are going.

Any thoughts on this?

12
  • I'm definitely interested in hearing from the community on this. We have close reasons for find or recommend tools, libraries, programming languages, resources (including books, blogs, tutorials, and examples), or projects to undertake which may include some of these questions, along with unclear what you're asking or too broad. We have valid reasons to close questions that can generate too many answers - that isn't a problem. Ensuring that we communicate the problems with these questions and how to make them good is going to be very important if we decide, as a community, to do this.
    – Thomas Owens Mod
    Commented Mar 20, 2017 at 22:41
  • 2
    I think we have a convenient dupe target for these questions: Choosing the right Design Pattern with the answer explaining in details what's wrong with shopping approach
    – gnat
    Commented Mar 21, 2017 at 5:29
  • I think a lot of those type questions have been closed more regularly recently under the "assistance in explaining, writing or debugging code" reason. Commented Mar 21, 2017 at 15:21
  • 2
    @gnat: though I think most of this question should be closed, I think what you are suggesting is abusing the "duplicate" closing mechanics. We give an extremely unhelpful and arrogant impression when we reply to very specific questions with a close vote to a 100 times more general question, which is probably too general to count as a real duplicate. We cannot expect most of those newbies to understand what we are trying to tell them that way. Better tell those people straight what is wrong with their specific question (or give them a reference to this meta post).
    – Doc Brown
    Commented Mar 22, 2017 at 12:32
  • @DocBrown consider raising at MSO similar concern about how it is unhelpful and arrogant to have 5,000 questions closed as a duplicate of single 100 times more general canonical question about NPE, I bet it will be fun to watch the discussion about this
    – gnat
    Commented Mar 22, 2017 at 12:39
  • 3
    @DocBrown To be fair, most people that ask "What Pattern should I use for X" have no idea how patterns work in the first place. Pointing to them a generic but otherwise complete question+answer showing why this is a bad way to tackle stuff seems to be a good idea, honestly.
    – T. Sar
    Commented Mar 22, 2017 at 12:50
  • @TSar: pointing them to a more generic question is fine, voting to close a question as a dupe of one which is no dupe is IMHO not a good idea. See Thomas Owens comment below.
    – Doc Brown
    Commented Mar 22, 2017 at 13:03
  • @DocBrown sorry I thought you know how it works. Okay, this link is a canonical question about NullPointerException. At that question page there is a link labeled "see more linked questions…" that refers duplicates (those that aren't deleted). If you click that link it will show you a page looking about like at this screen shot
    – gnat
    Commented Mar 22, 2017 at 13:14
  • 2
    @DocBrown Null Pointer Exception. They make the bulk of the closed questions on SO. Most of the time, it's just a matter of a not-initialized variable/parameter somewhere. It's solvable with some debugging but you need to have some understanding what you're doing and you need to understand your programming language. It's more or less the case with patterns - it's hard to help someone to solve a problem they don't fully grasp in the first place.
    – T. Sar
    Commented Mar 22, 2017 at 13:14
  • @gnat: I already figured it out, thanks. The reason I did not see much was because of my "ignore" tags on SO, which include "java".
    – Doc Brown
    Commented Mar 22, 2017 at 14:18
  • 1
    @DocBrown Hehe, that's actually a good policy to have on the ignore list :P
    – T. Sar
    Commented Mar 22, 2017 at 14:22
  • 1
    Just refer them to the Cargo Cult Pattern.
    – user251748
    Commented Apr 3, 2017 at 19:08

4 Answers 4

10

What's the best screw driver to use on a nail?

A hammer.

Some of the best answers on this site reject the premise of the question.

I completely agree that "give me the pattern" questions can be problematic. We should close them when nothing useful to the site can be made of them. But some can be redeemed with the right answer that points other lost souls to wisdom. Not everything can be solved with a pattern but that doesn't mean there isn't a solution.

The hard question at that point is how many other lost souls? It's hard to tell if this answer only helps the OP if you've never been so confused you thought a some kind of screw driver was what you should use on a nail.

So I say vote to close unless you can see where the confusion is coming from and can point to a good answer.

As for how to close them I like gnats dupe target. Just wish closing as dupe wasn't such a pain.

14
  • 3
    Closing these pattern shopping questions as a dupe of this question doesn't make sense. When you close as a dupe, are pointing people a question with a set of answers. The questions "what's the best pattern for..." and "how do I choose a pattern" are not the same question, which means they aren't dupes. Closing as too broad or unclear would be better. Linking directly to this answer in a comment is OK, since reading it should explain why their question is unclear or too broad.
    – Thomas Owens Mod
    Commented Mar 22, 2017 at 9:42
  • 2
    @ThomasOwens consider giving a read to answers in this discussion at MSE: Does the new guidance on duplicate questions suggest closing a question as duplicate, if the original answers the OP's question?
    – gnat
    Commented Mar 22, 2017 at 13:37
  • 3
    @gnat I don't agree with that advice. Beside, "we do it all the time on Server Fault" is by no means a network standard - it's how one community has defined duplicate. Even if it were a network standard, that doesn't mean that each community shouldn't evaluate it to see if it works - the standard is just a starting point.
    – Thomas Owens Mod
    Commented Mar 22, 2017 at 14:00
  • @gnat Just to be clear - if we want to interpret "duplicate" as meaning "closely related" or "the answers to this question are helpful" (like suggested in that MSE post you linked to), we can have that discussion. But I don't recall having that discussion previously.
    – Thomas Owens Mod
    Commented Mar 22, 2017 at 14:11
  • 1
    @gnat if you read into the other meta linked there (Changes to “close as duplicate” (part deux)) the guidance I get out of it is "do not vote to close as duplicate unless it is otherwise a good and on-topic question" similar to how we do not migrate crap to other sites. From what I have seen, most "shopping for pattern" questions are poor-quality and should be closed for other reasons anyway, not because they are duplicates. That avoids the whole "close as exact or close enough duplicate" argument.
    – user22815
    Commented Mar 22, 2017 at 15:30
  • @Snowman one thing this approach doesn't take into account is that system now allows short-circuit closing of duplicate if asker agrees that dupe target addressed their question. I rather prefer quick closure like that than wait until several 3K users agree and vote whatever other reason. Another thing is dupe vote offers an option to improve question by de-duplicating edit. I think it happened few times with pattern-shopping questions that turned into reasonable ones after shopping garbage was edited out
    – gnat
    Commented Mar 22, 2017 at 20:24
  • @gnat how often do users VTC their own question as a dupe, though?
    – user22815
    Commented Mar 22, 2017 at 20:56
  • 1
    @Snowman hard to tell without seeing deleted questions but of 5 visible duplicates of "Choosing the right Design Pattern" one is closed this way. Plus as I said I recall few others fixed by de-duplicating edits. If memory serves such edits were made by site regulars and not by askers but since result was okay I just happily retracted close vote
    – gnat
    Commented Mar 22, 2017 at 20:58
  • @CandiedOrange Yes, a hammer would be the best way to drive a nail, but that doesn't answer the question. Maybe the person asking doesn't have a hammer :) I think suggesting a hammer is great, but what I don't like is when the person asking the question acknowledges this and the community cannot accept anything but recommending the hammer. Commented Mar 27, 2017 at 19:43
  • 1
    @AnotherDeveloper As someone who's been confronted with metaphorical nails without even having heard of a hammer I place great value on a community willing to tell me about hammers and that I'm trying to do it the hard way. If I want to insist on doing it the hard way anyway I'll make that clear in the question by at least demonstrating that I have already considered hammers. Commented Mar 27, 2017 at 20:18
  • @CandiedOrange Questions that people ask are not so simple and clear as a hammer and nail unfortunately. I feel that the community is too "active" in trying to vet questions instead of just answering them. I'm tired of asking a question and preemptively saying I'm not doing A,B,C etc, and still be asked why I'm not doing A,B,C, etc. This happens too often. Here's an example from a question I just asked today: softwareengineering.stackexchange.com/questions/345014/…. I want help, not people online trying to "establish" themselves. Commented Mar 27, 2017 at 20:37
  • 2
    @AnotherDeveloper Nails are not "simple and clear" to those who never heard of hammers. However, I completely agree that Stack Exchange is a lousy help site. Do what I do: stop confusing Stack Exchange with a help site. Cause it's not. It's a Q&A site that doesn't care about helping you solve your problems. It cares about problems that many people will care about. If you can't write a question that will help many people don't expect answers that will help you. Helping you is the last thing you should expect us to do. This place isn't about you. Commented Mar 28, 2017 at 2:44
  • Gosh, everyone knows that you use a crowbar to straighten the old nails you remove, then drive them in somewhere else. Hammer? Bah.
    – user251748
    Commented Apr 3, 2017 at 19:12
  • Using a hammer on a screw with enough force can work as well.
    – Peter
    Commented Jun 20, 2017 at 7:00
7

You are correct, these types of questions tend to be problematic for a variety of reasons.

  • Too broad. Maybe multiple design patterns could work. Maybe none. Maybe the answer is a short novel on how to shoehorn in patterns.

  • Unclear. Often these questions tend to be light on details, as if the asker wants us to be mind readers.

  • Off-topic: resource request. This has a weaker justification in my opinion, although I have cast this close vote at time for some questions.

In my opinion, these questions suffer from one of two problems:

  • Asker does not understand how to design software, and believes applying a pattern will solve the problem.
  • Asker has a solution in mind, and needs to find out how to get there (X/Y problem).

The correct thing to do is put the question on hold for whatever reason to avoid poor-quality answers to a poor-quality question, and work with the asker to improve the question so it can be reopened and a proper answer written. Ideally, we would share our experience on how to design software beyond throwing a dart at the dartboard of design patterns.


See Also

These links are all applicable to some extent. Design pattern shopping is about "best practices" (applying a pattern thoughtlessly) which is a type of cargo cult programming (do whatever the popular thing is). They tend to be shopping for solutions instead of seeking advice to better oneself (give me fish/teach me how to fish). Finally, they are often X/Y problems: I think I need solution Y, when in reality I need help solving problem X.

3
  • I thought that Cargo Cult meant trying to get a result by simulating your understanding of the causes - like how people on Pacific islands created fake runways, etc to try to get planes to drop pallets of cargo. It has nothing to do with "popularity".
    – user251748
    Commented Apr 3, 2017 at 19:14
  • 1
    @nocomprende read the Wiki link: the idea behind it is including code components that serve no real purpose, implying that a programmer is adding them without understanding why they might be added. Often this is because they see it done elsewhere, so they blindly apply the same patterns or code constructs to another project where they might not be appropriate.
    – user22815
    Commented Apr 3, 2017 at 21:39
  • Isn't that what I said?
    – user251748
    Commented Apr 3, 2017 at 22:10
0

I tend to not like these questions either, but I also feel like there may be many developers who are using the term design pattern when they really mean best practices. Maybe a follow-up question along these lines to the OP would help clarify?

If they insist on a design pattern (I'd like to hear their reason why.), vote to close.

2
0

One additional reason someone may ask a "design pattern" question could be that they aren't aware of the terms associated with the particular problem that would enable them to begin learning and finding a solution. For example, if someone had never heard of state management and related tools such as Vuex or Redux then it would be reasonable for them to ask a question such as "Design patterns for managing shared data across multiple web pages". In this case, the person may actually need someone to point them towards the terms "state management" and "vuex" or "redux" so they can begin to learn rather than handing them design patterns. The very nature of not knowing the correct terms for a problem prevents a developer from learning and leads to generic questions in the hope someone will be able to give them anything they can latch onto and begin learning. Without a few tips from someone who knows the domain it will take them a long time to find the terms they actually need and begin growing in that particular domain.

I do not make this point to say we should start allowing these types of questions. Rather, I think keeping this perspective in mind can help us to leave more helpful comments as we seek to close unhelpful questions. In addition to pointing people to reasons why the question is unhelpful we could also include something like "hey, sounds like you are trying to figure out x. maybe google these terms or check out this resource to get some of the basics".

1
  • 1
    What you describe are questions which might be reworded into "Is there a term for ...". Well, some of our community members here downvote and close such questions categorically ("needs more focus"), and I do the same, for the reasons mentioned here, if I perceive such a question as an unfocussed guessing game question. So that perspective may be an additional reason for closing, not against it.
    – Doc Brown
    Commented Sep 18, 2021 at 7:36

You must log in to answer this question.

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