Let us assume that someone posted a question about allocating a 2D array in C++, his code doesn't compile because he has errors in it.
Now after you read the question, you see that he should use std::vector becuase it's better and more recommended in his case. But he's asking about arrays and not vectors.

Now let's say someone posts an answer that solves his problem (with an explanation), but std::vector is not mentioned in the answer (as OP wasn't asking about vectors).

Should this answer be downvoted because it doesn't suggest a better solution? Or it's fine because it solves OP answer?

  • 8
    Why would you downvote a good answer for a bad question?! Shouldn't you downvote the bad question instead? – SudoRahul Oct 28 '13 at 7:52
  • 2
  • @R.J I don't mean that the question itself is bad, what I mean is that the OP is still a beginner and doesn't code a "beautiful" and efficient code. I think that we should correct his mistakes, and not suggesting something "better" (that might be more complicated) and won't help him to better understand his current mistake. – Maroun Oct 28 '13 at 7:54
  • 3
    @MarounMaroun - In that case, you SHOULD go ahead and post an answer suggesting why using vector's would be helpful. Downvoting an answer which actually fixes the OP's original problem doesn't seem right(though votes are absolutely your right and nobody can advice you on how and where to use it). – SudoRahul Oct 28 '13 at 7:57
  • @R.J Yes, but it doesn't answer the OP question since he'll not learn from his mistakes. I remember that in my university, we had an exercise to implement String class in Java (Now if I posted a question about that, someone would say "don't reinvent the wheel").. Sometimes someone learns the basics and doesn't have to know about vectors or whatever in this stage.. – Maroun Oct 28 '13 at 8:02
  • Sorry, but I wasn't exactly able to grasp it. Are you saying that the answer you might post(with the suggestion of using vector) won't answer the OP's question? – SudoRahul Oct 28 '13 at 8:06
  • @R.J Yes, because he's actually asking about arrays, so he has no idea what vector is.. :) – Maroun Oct 28 '13 at 8:07
  • @MarounMaroun - In that case, its upto you, whether you want to leave a answer/comment for the OP to consider using a Vector which might help him, or else, just move on. If you really feel that this might help the OP very much, I strongly urge you to go ahead and post it as answer. It might not help this OP now, but it might be very useful for some other user in the future. – SudoRahul Oct 28 '13 at 8:12
  • 1
    @MarounMaroun: Late to the game here, but why not simply do both? Here's the answer to your problem, but here's also a better way to do it. Then the OP learns from his mistake, plus learns a new better method. – Chris Pratt Feb 5 '15 at 21:30
  • "Should this answer be downvoted because it doesn't suggest a better solution? Or it's fine because it solves OP answer?" -- Neither. It's not "fine", but a comment is far preferable to a downvote. "votes are absolutely your right" -- wrong. "nobody can advice you on how and where to use it" -- of course they can. "it doesn't answer the OP question since he'll not learn from his mistakes" -- non sequitur. – Jim Balter Jan 13 '17 at 8:38

You are entirely free to choose how to vote.

That said, why should genuine answers that you find helpful be punished for the quality of the question? I vote on the merits of individual posts, myself.

Moreover, I try in my answers to help the question asker as best as I can. If that means pointing out that the OP is barking up the wrong tree and that a different technique is better, then I certainly will do so.

For example, when a question asker asked about removing newlines from quoted CSV values, I didn't give him the requested regex to do so but instead pointed to the CSV parser that handles newlines in quoted values correctly.

If the answer fixes the underlying problem, then why would that answer be wrong or unhelpful?

| improve this answer | |

I don't think you should down vote the answer. You could post your own with an alternative solution and explanation why something else is better to do in the case.


Consider the scenario when someone requirement is to use a 2D array instead of vectors - could be homework, work-related, learning from book where the OP has not reached the vectors sections or something similar.

If the question is specifically about the 2D array just make sure you are not radically changing the meaning of the question giving an answer.

Your statement

but it doesn't answer the OP question since he'll not learn from his mistakes

is what we call Primarily opinion based. I don't think you should put yourself in a position where you're judging whether the OP is going to learn or not from an answer provided(not by you). You have the right to downvote any question or/and any answer.

The idea of asking a specific-programmatic question is to get a specific answer to the question asked. If the OP asked for a 2D array solution then that's what he was interested in.

I suggest to take advantage of the comments section below the question. If something is unclear or if you would like to propose another solution then simply ask the OP:

have you considered using vectors to solve your problem?

| improve this answer | |

In such a case, you should actually go ahead and post an answer to that question suggesting why using vector's would be helpful. That's the purpose of SO, isn't it. Even if the OP doesn't use vectors, there might be a user in future who would come looking for an answer for a related question and might find your answer very helpful.

Having said that, I also feel downvoting an answer which actually answers the OP's original problem doesn't seem right (though votes are absolutely your right and nobody can advice you on how and where to use it).

| improve this answer | |
  • "though votes are absolutely your right" -- wrong. An obvious counterexample is a person who downvotes all of someone's questions and answers because they don't like them. Malicious downvoting is morally wrong and there are bots that look for it. "nobody can advice [sic] you on how and where to use it" -- of course they can, especially when the OP explicitly asks for such advice. – Jim Balter Jan 13 '17 at 8:42

If question is unclear, answer can get downvoted because voter's interpretation was different and answer did not cover it at all, or was outright wrong (for that interpretation of a question). Same with questions that are too broad. And for off-topic (in English language meaning of that term) questions, answers are usually off-topic as well.

If answer works, but encourages bad practices, I would suggest to comment first, and give answerer's some time to fix it. But downvoting to push it behind good-practices answer seems like perfectly legitimate use of votes, too. Harsh, not nice, but legitimate and useful at the same time.

Thus, there are many perfectly valid reasons to downvote helpful and properly written answer to a bad question, that are not "punishing for question's quality" directly. Only punishing for answering duplicates seems outright and clearly wrong to me - if someone knows it's a duplicate, it's his (and others like him) fault it isn't closed yet, not the guy's who answered it.

| improve this answer | |

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