-3

I noticed a question where the answers, including the accepted answer, have bugs in their code snippets. Aside from these problems, the answers are relevant to the question and otherwise of an acceptable quality.

I pointed out that these answers probably should not be accepted and upvoted unless the code is fixed, as the code snippets will be unhelpful to anyone who tries them out. However, this concern was dismissed as irrelevant to the author of the question. I'm curios if Stack Overflow has policy guidelines about what should be the preferred course of action in this case?

The guidelines for code editing say that changing the code logic or functionality is not a welcome edit, so it's clear anyone except the author of the answer should refrain from fixing the bugs even when the fix is obvious.

Edit: My problem is that a system which encourage technically incorrect and sloppy answers de-incentivizes people to do good work in crafting answers, as well as decreases the reputation of Stack Overflow in the long term. I wonder if "teaches something, just incorrectly" is really the kind of answers Stack Overflow should have. To push this further, would you want a textbook where the code examples are incorrect and "the solution to fix them is left to the student"?

8
  • When you say that the code snippets will be unhelpful to anyone who tries them out, do you mean that the bugs are so severe that they actually break the answers beyond answering the question?
    – BoltClock
    Aug 17, 2017 at 15:17
  • In that case the idea is correct, the implementation is not. Moving from the concrete to the hypothetical, do you think that this question could be a good way to decide which action to take?
    – kfx
    Aug 17, 2017 at 15:19
  • 3
    Nothing is set in stone, the OP can trivially select another answer. All you have to do is post a better solution. Aug 17, 2017 at 15:36
  • @HansPassant the OP indicated that he does not care about the code in the answers.
    – kfx
    Aug 17, 2017 at 19:27
  • @kfx If you think future readers are likely to actually care about the code, and not want a flawed implementation, you can provide your own. If you don't think future readers will need an implementation, and will also be fine with just an explanation of the algorithm, then there is no problem and no need for a new answer.
    – Servy
    Aug 17, 2017 at 19:36
  • 3
    The system doesn't encourage incorrect or sloppy answers. It's possible for the community to do that if users decide that those answers are good. I honestly can't think of any action to take (other than the ones in Servy's answer) that would be both fair and scalable.
    – BSMP
    Aug 18, 2017 at 2:39
  • @BSMP What about adding a feature to the SO user interface that would nudge the users to test their code before submitting? SO already supports embedding of executable JavaScript fiddles, perhaps using them should be encouraged: stackoverflow.blog/2014/09/16/… That would improve the probability that the code runs without exceptions and works on one or two simple examples. SO interface is already doing a great job in helping thousands of people to write better questions, could move further in this direction.
    – kfx
    Aug 18, 2017 at 9:53
  • @Servy I provided my answer, as suggested.
    – kfx
    Aug 18, 2017 at 10:32

1 Answer 1

9

If you feel that the answer is unhelpful, you can downvote it.

If you want, you can comment on the post to describe how the author could improve it.

You can post your own answer to the question that you feel is going to be better; if you end up incorporating portions of an existing answer into your own answer when doing so that's fine, just be sure to cite them appropriately.

If someone else feels that there are problems with an answer, but those problems don't inhibit the answer from being useful (say, because there are minor errors that are easy to find and fix, and so are not a significant detraction to the quality of the answer) they are of course able to express their own opinion of the quality of the post with their own vote, just as you can express your opinion with your vote.

6
  • Clarification request: Do you mean unhelpful to the question's author, unhelpful to me, or unhelpful to the people who will arrive at the answer later on e.g. using a search engine?
    – kfx
    Aug 17, 2017 at 15:21
  • 2
    @kfx Unhelpful as an answer to that question in general, not with respect to any one person.
    – Servy
    Aug 17, 2017 at 15:22
  • 1
    Yes - an easily fixed typo in code that would otherwise clearly explain a solution to OP's problem should not be an issue. Users see the code, maybe incorporate it, get a compiler error and fix it. Not a problem. Aug 17, 2017 at 15:25
  • Thanks @Servy, I went and did downvote the accepted answer after reading your reply.
    – kfx
    Aug 17, 2017 at 19:29
  • @MartinJames I don't think compilers are very good at sorting out whether the code does what it is supposed to do.
    – kfx
    Aug 17, 2017 at 19:29
  • @kfx Martin wasn't referring specifically to this one example, rather, he was giving a hypothetical of other situations in which "incorrect code" wouldn't actually be disruptive to readers. Martin wasn't making a judgement as to whether your specific example was such a case or not.
    – Servy
    Aug 17, 2017 at 19:32

You must log in to answer this question.

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