13

If a question is posted to which there are two (or more!) viable solutions, is it better to post it in a single answer with both solutions in (with perhaps a horizontal rule between) or as two separate answers?

I know that the system allows the posting of multiple answers, but what is the community's preference on this?

5
  • Personally I would rather see it as two separate answers. Commented Aug 22, 2014 at 14:51
  • 2
    In addition I would also consider voting to close as too broad in these cases.
    – Schorsch
    Commented Aug 22, 2014 at 15:24
  • 3
    @Schorsch How about the case of, for example, "How do I get a list of Names from a list of People objects in C#?". Answer 1: var names = new List<string>(); foreach(var person in people) { names.Add(person.Name); } Answer 2: var names = people.Select(person => person.Name).ToList(); - both completely correct, two completely different answers.
    – dav_i
    Commented Aug 22, 2014 at 15:27
  • 1
    I can imagine situations where you can have a limited number of useful, different solutions. However, with the questions I remember in that category, they spawned lots of answers where users provided "their way" of doing it, which is not always helpful.
    – Schorsch
    Commented Aug 22, 2014 at 15:29
  • 2
    Truth is, @dav_i, I'd post those as a single answer. The second is just a LINQ query that is doing the exact same thing as the first under the hood. You'd probably lead with the LINQ solution, and then mention that LINQ is only available starting with whatever version of .NET it was introduced with (who remembers that?) and give the first as a fallback.
    – Cody Gray Mod
    Commented Aug 22, 2014 at 15:39

2 Answers 2

20

It depends…are they two completely separate solutions, or are they somehow related?

If the two solutions are "two sides of the same coin", then I'd put them as a single answer. Either separate them with a horizontal rule, or—better yet—use headings (# in markdown) to separate them.

If they are two completely separate things that have nothing to do with one another, it would probably be best to post them as separate answers. Not only is that somewhat less confusing, but more importantly, it allows the community to vote on them independently. This provides a more accurate judgment of their merits. If you'd combined them in one answer, and I thought one of them was stupid but the other was a good idea, how would I vote?

1
  • 6
    Maybe flip a coin? Commented Aug 22, 2014 at 19:23
-2

I would rather see a single answer, because then it can get accepted as the "right answer".

This may seem strange--isn't this a case of two answers masquerading as one? How can you call such a thing "the right answer?"

But there are two possible definitions of "right answer", at least in the context of accepted SE answers:

  • the OP's favored solution for this problem
  • the canonical source for correct information regarding solutions to this particular problem

As should be obvious by now, I believe that the second definition is more useful and is more in keeping with the spirit and goals of the site.

0

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