6

Recently I've seen quite a few questions on the same topic, where each had a different problem (with provided code), but all stemmed from the same misunderstanding of the language feature being used.
Most the questions have a specific solution to their exact issue with concise answers but I thought it could be useful to have an explanation of how and why the common misunderstanding and misuse of the feature causes problems.

I was planning on 'Answering my own question' with an easy to understand simplified example, but I'm not sure if it would be better / more appropriate to write out this answer under an existing question.
Obviously i want to to avoid potentially duplicating a question, but I'm not sure if a longer more generic answer would be inappropriate for "here is my problem, here is my code, please help" style questions (especially ones that already have an accepted "here is the solution" style answers")?

Are, This is a common misuse of this feature, "Why is my code doing issue?" then "here is why this use of this feature is wrong and this is how to use it correctly" generic style Q&A questions suited for SO?

1 Answer 1

3

We call these canonical questions and answers. We have advice on how to write one and a tag for discussing them here on Meta.

Canonical questions are those that have the many arms of duplicates pointing back to it as the one truest presentation (or near enough) of the problem. In other words, the most cited when duplicate questions are found.

Canonical answers are those posted to a question that serve to cover all others in their breadth, research and utter tremendous weight of reason and accuracy.

These two post types often find themselves on the same page.

One well known canonical question is the Java What is a NullPointerException, and how do I fix it?. It does have more than one answer as people try to cover all the bases there but if you ask a question about Java code that's suffering from a NullPointerException, chances are you'll just get duplicated to that.

So if you're going to write a canonical question and a corresponding canonical answer then yes there are quite a few of those and it's certainly something that is encouraged here if you can do it well enough.

You must log in to answer this question.

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