2

Many times I've seen beginners ask questions that could be answered better with a more intimate understanding of the language. In such cases, should answers to such questions reflect the level of experience of the asker? In other words, should the answers be written as if by someone with the asker's equivalent level of experience so it is better understood by them? Or is it okay to introduce new concepts that would help provide a better solution, even if those concepts may be outside the comfort zone of the asker?

For example, let's say someone asked how to check if an array has duplicate elements. They might propose a solution like this that they are struggling to get correct.

boolean hasDuplicates(int[] array) {
  for(int i = 0; i < array.length; i++) {
    for(int j = 0; j < array.length; j++) {
      if(array[i] == array[j]) {
        return true;
      }
    }
  }
  return false;
}

Of course, you could simply propose a solution where you also check that i != j and be done with it, but you could also give a more advanced solution like this that the asker may not be familiar with.

boolean hasDuplicates(int[] array) {
  Set<Integer> seen = new HashSet<>();
  for(int i : array) {
    if(seen.contains(i)) {
      return true;
    } else {
      seen.add(i);
    }
  }
  return false;
}

In this instance, we're using a Set object, and an enhanced for loop. I'd prefer to give this answer, as it is a better algorithm in terms of time complexity, but I also don't want to overwhelm the asker or have the solution go over their head. What is preferable?

  • 1
    It is preferable to give the best answer. What is best depends on context. You're not restricted to give one solution, you can offer multiple ways to achieve the same outcome, outlining how each solution differs/how they are best applied/used, what benefits/caveats each has. – rene Jan 29 '18 at 14:14
  • 1
    Possible duplicate of Would user-set experience level be helpful in question tags? – gnat Jan 29 '18 at 15:47
  • 3
    @gnat I don't see how a question about responding to the (in)expertise in the question is a duplicate of a request to explicitly label expertise levels. – Monica Cellio Jan 29 '18 at 16:26
  • That code is a poor answer since it doesn't meet the spec(ification). Even if it met the runtime spec by not adding, it unjustifiably assumes the implementation spec allows access to certain libraries or that the spec can be changed in a certain way. A correct answer to a question could reasonably involve introducing & explaining new concepts etc that aren't used in the spec or question. Then there is the usual quality of answer issue. But before you start answering hypothetical specs & questions you should ask for clarification to find out what the actual spec & question is. – philipxy Feb 1 '18 at 2:47
6

The best answers are accessible to a range of readers. Even if the asker seems more advanced, explaining why you're saying what you say, instead of just saying it, helps other readers who have the same problem and find the question and its answers. This is akin to the "show your work" or "back it up" rule used by many sites -- the goal isn't just to answer the question but to show why it's a good answer.

On Mi Yodeya, where our subject domain inherently includes a lot of jargon, we've codified our guideline as follows:

When writing questions and answers on Mi Yodeya, the overall guiding principle you should have in mind is: Will any English speaker who is interested in this content be able to understand what it means without additional research?

I recommend you follow a similar approach in writing answers on any site. Note that if the problem is advanced and specialized, something a beginner couldn't encounter, then it's ok to just write at that expert level! Answers should be understandable to anybody who could understand the question, but if somebody on Physics asks an advanced question about quantum mechanics, answers don't need to start with the basics of the field.

Calibrate your answers to the question, not to the asker.

You must log in to answer this question.

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