0

I have a hard time with asking “is it okay”/“is it good practice” questions in ways that the community deems suitable for this site.

I see popular and high-scoring questions about good/bad practices and patterns:

On the other hand, my “best practices” questions get closed as opinion-based:

Can I ask whether coding patterns are good or bad? If so, how should I ask? What have I done wrong in the way that I asked these questions? How can I improve them to make them on-topic?


Edit : All of the high-score questions listed above were asked years ago. Did the rules change since? Is opinion-based question closure far stricter nowadays? Where are the rule changes documented?

1

1 Answer 1

6

It is really difficult to ask a good question about best practices, as also discussed on MSE: Why is asking a question on "best practice" a bad thing?

In a nutshell, asking about best practices implies that there should be a wide consensus about something, but in practice things are more complicated. If best practices exist, it doesn't necessarily mean the best practice should be followed. If no wide consensus exists, the question is likely to elicit unsubstantiated opinions, which does not serve the site's goal of building a library of questions and answers that helps other people in the future.

Good questions on this site generally feature a specific, concrete, and solvable software engineering problem. Typically this is a design-level question, but can also relate to process-level issues. In some cases, the problem to be solved is insufficient understanding of a widely understood software engineering concept. However, questions asked out of mere curiosity, without an actual underlying problem, often lead to very poor questions. An X-Y Problem occurs when a question is asked about a potential solution instead of the actual problem, which also typically leads to poor questions. Good questions don't just describe the problem with sufficient context, they also show an independent attempt at solving the problem. This is not just polite to the community, it also helps explain further constraints by explaining why an obvious solution wouldn't work.

The positive examples you mention have a median age of about 7 years, so they are not necessarily useful to inform our understanding of the current scope of this site. The examples of best practices questions that you can still find will be subject to strong selection bias: most will have probably been closed and deleted, and only the better examples will have survived.

Specific remarks about your examples:

  • (2014) Should I place functions that are only used in one other function, within that function?

    This is not necessarily the greatest question. It poses a problem, albeit a hypothetical one. It asks about something where no strong consensus exists.

    Nevertheless, it happened to receive two very good answers that analyze the problem from various perspectives and discuss solutions. The question is definitely worth preserving for these answers.

  • (2010) Is it OK to have multiple asserts in a single unit test?

    This is not a great question – it explicitly asks about opinions about a quote. Per Discuss this ${blog}, such questions are now not generally acceptable (but back in 2010 this site had a very different scope).

    But the underlying problem is of broad interest, and it received some useful answers. And given the massive number of votes, it should be retained due to historical significance.

  • (2018) Is it bad practice to enforce an execution order for unit tests?

    While it nominally asks about “best practices”, there is wide consensus about that matter. A rare example of a best-practices question that is actually objectively answerable.

    This is actually a great question because it describes a concrete problem that the poster is facing, and demonstrates independent attempts at solving the problem.

  • (2014) Are error variables an anti-pattern or good design?

    Similar as previous. Nominally about best practices, but wide consensus exists and is objectively answerable.

    Not as great as the previous example, but it still demonstrates a clear problem (how do I communicate errors without halting execution?) and shows an independent attempt at solving the problem (looked at PHP's msqli API).

  • (2013) Is it a good practice to create a ClassCollection of another Class?

    The question is nominally about best practices in general, but is clearly about a well-defined concrete design problem that can be answered. It received a great answer.

What strikes me about your three examples of closed/deleted questions is that they are very code-oriented, and are not about design-level issues or other aspects that are within scope of this Software Engineering site.

Specific remarks about the examples:

  • Should one capitalize the first letter of a lowerCamelCase variable name if it starts with a proper noun?

    That is not a Software Engineering issue, it is not even opinion-based, it is purely a matter of style and which style guide applies depends on the project. If the answer to a question can be simply looked up in other reference material, it is probably not a good fit for the Stack Exchange model. However, answers to such questions are likely to only voice subjective opinions, so the question was correctly closed as opinion-based.

  • Is it a good practice to always apply CSS styles to the innermost nested element?

    The question assumes that a best practice exists where there is none, and whatever design is chosen it doesn't really matter. The answers/comments try to encourage you to look past the structure and move towards more semantic CSS, but I don't expect this Q&A to meaningfully help people in the future.

  • Is it good practice to debug with inline console.log in expressions?

    Again, the question assumes that a best practice exists where there is none. Since this is a fairly niche issue, an answer that explains the lack of best practices would have limited value. More likely, answers would just voice subjective preferences so it was correct to close the question as opinion-based.

As a general observation, the combination of your display name (“clickbait”) and the less professional, more meme-y code examples (“Gucci gang”) are unlikely to help with a positive reception. This might negatively bias voters/reviewers. At first glance, some of these questions even look like an attempt at trolling. In any case, they are short and low-effort, without demonstrating an independent attempt at solving the problem.

You must log in to answer this question.

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