What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 122 Stack Exchange communities.

I have read this: Why do you cast downvotes on answers? and tried searching for a specific view on this scenario but cannot find. If there is a question covering this already I apologize.

Q: Would you downvote a "code only" answer, where the code works as given but has no explanation as to how/why it could work with regards the question?

share|improve this question
1  
may be because it is not guarantee that who has given the answer actually owns it. It may be a copy from net and answerer doesn't know what is going on the code just found on net and posted it. –  Harry Joy Jun 17 '11 at 10:28
1  
@HarryJoy That doesn't qualify it as a valid answer. –  Octavian Damiean Jun 17 '11 at 10:42
    
@Harry, hadn't even thought about that scenario, if that was the case that would make it worse :o –  clairesuzy Jun 17 '11 at 10:59
1  
@clairesuzy: that is the first case I got on mind. –  Harry Joy Jun 17 '11 at 11:12
4  
@Octavian - why isn't it a valid answer? It might not be one you like (and I'd agree with you) and it might be a weak answer but it's possible for it to be a perfectly valid answer. –  RobM Jun 17 '11 at 11:29
1  
@RobertMoir I don't see how someone that does not understand the code he copy/pastes will be able to provide that code as an answer. Logically it does not make any sense. –  Octavian Damiean Jun 17 '11 at 11:33
3  
@Octavian - I'd agree that its unlikely, but even a blind squirrel occasionally finds a nut. –  RobM Jun 17 '11 at 11:36
    
I may be completely off my tree but I did down vote eventually, even after saying I wouldn't .. the "code only" answer was not acknowledged or accepted (though it had the highest votes?) but as I said in comments when pressed for an answer the answerer refused to give an explanation. and is still arguing the fact why he or she should? So I just had to DV, last straw, so it seems circumstances are everything as a few of the replies here tell me :) thank you for your views they helped through watching a scenario unfold! –  clairesuzy Jun 17 '11 at 23:38
1  
Before you ask: Downvotes on Meta are different. –  slhck Jun 3 '12 at 17:47
2  
There are no "welcome gifts" or anything here. We assume everyone's read the FAQ and How to Answer. We generally don't vote differently for high reputation users or new users. Posts are supposed to be voted on based on their merits alone – regardless of how long you've been a member. Just try to make your answers stand out and explain a little. In the long run, this will get you more upvotes. –  slhck Jun 3 '12 at 17:56
add comment

11 Answers

up vote 29 down vote accepted

Not by itself. This would depend on a couple of other factors I'd say:

  • Let's assume it is devoid of code comments too.
  • But is it readable code?
  • Is it self-explainatory or confusingly named?
  • Does it answer the question specifically (variable names) or is it a generic 08/15 code snippet from a manual.
  • Was the question just asking for a code fix, or did it deserve a textual explanation/advise?
  • Does it work anyway?

Otherwise it would fall in the same category as one-liners sans reasoning.

share|improve this answer
1  
I'd emphasize specifics of the question as well. For example, a question clearly from someone new to programming or the language/paradigm will likely need an explanation, whereas someone clearly an experienced programmer may not need any more than the code snippet as they're able to figure your answer out on their own. –  Servy May 31 '12 at 15:08
add comment

Seeing as there are so many other code-only answers in that question (and many similar ones), it indeed seems a bit unfair to single you out. (Edit: you weren't singled out after all - your answer was caught by the "review" tool because you're new.)

But the best thing to do is to just shrug it off, and go on. Votes aren't that important. Every SO user is free to cast them as they like - and they're all individuals from all over the world with varying views, opinions, and standards. We all receive downvotes occasionally, and we will not always agree with them - don't take them too seriously.

share|improve this answer
    
I didn't single him out, see my answer below. –  Manishearth Jun 3 '12 at 17:57
    
@Manish yeah, I see. (The existence of other code-only answers on that question that didn't have downvotes made it look like you did, but I guess this was the review tool's "fault"...) –  Pëkka Jun 3 '12 at 17:58
add comment

I wouldn't downvote it. But neither would I really upvote it. There's nothing to 'punish' or inherently wrong there, so you don't have to to downvote.

share|improve this answer
    
that would normally be my way too, but an example is a bounty question where others have upvoted it, whereas there are answers (with less votes) that are correct for the scenario and have explanations –  clairesuzy Jun 17 '11 at 10:56
    
@clairesuzy you could upvote the rest. Of course this isn't a hard and fast rule. I usually reserve DVs for something that is blatantly wrong. You could also leave a comment asking the user for an explanation before the DV –  JohnP Jun 17 '11 at 10:58
    
true.. about the UV's -and in the answer, that prompted my question, someone has already asked the answerer for explanation, they replied "no, not unless asked someone asks" (they just did didn't they?) hehe anyway I'm not going to DV in this case as I have also now answered the question and it just might seem like sour grapes –  clairesuzy Jun 17 '11 at 11:05
add comment

The tooltip for downvoting says "this answer is not useful" and it's a pretty good standard to apply. Often "just code" answers aren't useful, or at best they could be a lot more useful with an explanation.

Code-only answers could almost always be improved by explaining what the code does, why you wrote it this way, why it solved the problem and so on. They are inherently not the best answer possible, even with the information you obviously know. Lack of effort and explanation are "encouraged" reasons for downvotes in my book..

share|improve this answer
add comment
codeOnly != badAnswer

Especially if the asker posted something along the lines of "What is the syntax to exit a loop?" etc.

share|improve this answer
add comment

Depends on the situation. For this question, I would definitely downvote a code-only answer.

share|improve this answer
    
haha.. so would I ;) –  clairesuzy Jun 17 '11 at 11:08
add comment

I, personally, have seen too many one-liner-code-only posts on SO, and I'm trying to fix that by downvote+commenting on bad posts. I don't single users out, they usually appear in /review/. I often handed out ~40 other such votes daily.

Basically, a code-only answer doesn't help other visitors learn. It doesn't help anyone learn. That doesn't make the Internet Better™, that just helps us degrade into a quick-fix forum.

Please write substantive answers.

Shameless self plug: Check out the other voting faq

share|improve this answer
add comment
/No/

share|improve this answer
4  
Is that a new 4chan board, or an unnecessary regex? –  BoltClock's a Unicorn Jun 17 '11 at 17:09
    
@BoltClock, it would be unnecessary regex but it does more look like code than just No. –  YOU Jun 17 '11 at 17:22
add comment

I do. I even flag those answers. A bunch of code is not a valid answer. At least a few lines of explanation is not too much to ask for.

A valid answer for me is something which does not only solve the problem but also explains the user why it solves the problem. The reason behind it is that I think we should not only share text but knowledge.

share|improve this answer
add comment

I don't remember downvoting code-only answers, but I'm inclined to do so now.

The reason is that the context of why the answer works would be shared only between the original poster and the answerer. A person reading the code snippet later, may have no idea as to why the answer is valid. Ok, granted there will be snippets that will not fall under the previous definition, but that is not the point.

The point is that, the answer is useless to anyone not knowing the subject very well. This is as good as going on ServerFault and providing a shell script that has rm -rf / to a novice with the adjoining line: "Run this!! This will solve your problem". Ok, most people would know that, but who would know drop table dual in the context of Oracle. In plain and simple words, the likelihood of an answer being verified by multiple people reduces with code snippets that are undocumented.

PS: The answers of type "Look at this link. The answer is here." should also fall under this category.

share|improve this answer
add comment

I will surely surely down-vote it!

Because if you are posting only a wall of code, though it works and OP just copies it and execute it and enjoys whooo!! the code works for him. OP was successful in coming out of his issue but what about his knowledge about why that issue was coming? What if he faces similar kind of issue next time.

I will also say that its because of "code only answers" many OP's are forced to ask similar question again many a times. Because OP has no clear idea about how the code in other answers work as they are without explanation!

So, it better to spend 5 mins, explaning the issue/problem/mistake that OP was doing in his code due to which he was not able to make it work!

share|improve this answer
add comment

You must log in to answer this question.

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