15

A question is raised and two answers are posted:

  • The first is a solution that adheres to best practice and industry convention
  • The second uses a kludge to get the right result

How should voters act in this situation? Am I encouraged to vote up an answer simply because it answers the question? Should I be down-voting an answer that strays from best practice?

For example, someone may ask how to pull out an attribute from a specific line of XML:

  • Answer 1 would demonstrate use of XPath
  • Answer 2 uses a regex to extract the attribute.
0

8 Answers 8

21

I would upvote Answer 1 and not upvote Answer 2. Correctness is about more than just accomplishing the end goal. In other words the ends do not justify the means.

A good answer needs to not only provide a solution but it needs to provide a solution in a manner that adheres to best practices.

I wouldn't downvote the second answer but I don't think it deserves an upvote along with the better answer simply because it works.

1
  • 4
    One could add a comment to answer two about its problems.
    – Richard
    Jul 3, 2009 at 10:48
8

This is where the lack of granularity of up/down votes gets sticky. For me, you have three categories:

  1. Answers which provide the right information - these get upvotes
  2. Answers which provide incomplete information or a solution that works but isn't a particularly good idea - no vote of any kind, perhaps a comment explaining the shortcoming
  3. Answers which don't answer the question, are factually wrong, or are simply so terrible as to make me sad - downvote

Of course, I doubt even half of the community treat it the same way, which is either a blessing or a curse, depending on who you ask.

2
  • 1
    I down-vote answers that use the same verb twice in the same sentence.
    – Shog9
    Jul 2, 2009 at 17:21
  • @Shog9: Oh, I thought that was so obvious that I didn't bother to mention it. Jul 2, 2009 at 17:25
4

No, you should edit it and make it correct and safe. Or failing that, identify the scenarios in which it will break badly, and point them out via comments... Then down-vote with self-righteous fury at the short-sighted programmers now-a-days.

4

In my opinion, bad advice is worse than no advice. The bad advice could be taken to heart by a novice who doesn't know any better.

But whether or not to downvote, to me, really depends on how much of a kludge the second answer is. If it is a particularly bad kludge, I would downvote it. If it seems to have received more upvotes than it deserves, I will downvote it. Otherwise I'd just leave it.

I would always leave a comment explaining why it is a bad idea (or upvote an existing comment which says why). I think a comment with 8 upvotes that says "wait a minute this is a bad idea" would deter users more than a negative vote total.

2
  • 1
    I'm not sure I agree with this. For a novice user - or for an advance one, really - after banging my head against a problem, I'd much rather have a bad solution than none at all. It kinda seems elitist to say (to oneself) "I have an answer that would work, but it is a dirty hack - so I won't even mention it." Its all helpful, and all helps spawn new ideas and discussion.
    – user3788
    Jul 2, 2009 at 21:18
  • @rascher Agreed, but I suspect many people will not post a "dirty hack", no matter how helpful it is, for fear of being downvoted. Unless every bad answer starts with "FILTH ALERT" in big bold letters :) Jul 3, 2009 at 6:53
3

I think this is precisely how and why the SO voting system works. Some will look at that and upvote both, many will upvote the first and not vote on the second and a few may downvote the second as bad practice. Personally, I'm not inclined to downvote for something that works but is not best practice because there is a better way. But regardless, in the end I believe the votes work themselves out so that the answer with the best practice in it ends up at the top and the one that works but might not be advisable is second in line, above those that don't answer the question at all.

1

It could be that the asker cannot use XPath for some reason, then he is happy for a workaround. Even it is dirty (yeah, you are right, there are no clean workarounds).

1
  • This is why I think it's useful to leave "not the best" answers alone. Maybe the top answer is the best, but sometimes "worse" answers are still helpful. Sep 4, 2012 at 20:10
0

I would say vote up the most correct answer (at the time of your voting). So in your example, I would vote up the XPath answer unless the questioner specifies that he doesn't have a real XML library and so couldn't use XPath.

0

I would downvote only if the kludge answer out-scores the best-practices answer. It's all about having the best answer float to the top. Then I would probably also leave a comment letting the answer know why.

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