46

There's ample evidence of previous discussions about Code-Only answers, which all reach the (reluctant?) consensus of code-only answers being acceptable (as in shouldn't be deleted), but up for downvotes.

So why am I bringing this up?

I hope to solve or at least mitigate one or more of the following problems with SO by making code-only answers undesired:

  • FGITW Answers that dump possibly working code on people
  • People getting free fish, not getting a fishing rod and a fishing tutorial
  • "Can I haz teh codez"

Coming from our sister-site Code Review I came into contact with the iron rule, that answers without explanation are subject to deletion. This policy is strictly enforced by moderators and high-reputation users likewise.

While Code Review has a significantly different model than Stackoverflow, there is a common element:

Give a man a fish, you feed him for a day; Teach a man to fish, you will feed him for the rest of his life

As a result of this policy, users gain significant understanding of the subject matter which results in huge learning effects, making the internet a better place not only for these single users, but for all people who read such answers. Also answers are subjectively of higher quality in the mean.

Code-Only answers is equivalent to handing out free fish, and it's a strengthening factor for the problems I mentioned above. I think it's one of the reasons that FGITW works, that people post "Can I haz teh codez" questions and receive answers.

Additionally free fish often results in users not understanding the code they use later and when the time comes to modify it, they have "no choice" but to ask another Stackoverflow question, which shows similarly lacking understanding. This just amplifies the flood of questions.

Moreover every so often new-ish users join the ranks of community-moderation and time and time again they come to meta asking why code-only answers are not deleted. I conclude they intuitively think that code-only answers should be delete material. And time and time again the wall "Code-Only" is an attempted answer, so it shouldn't be deleted stops them in their tracks. Even experienced community moderators with thousands and thousands of reviews under their belts say (freely adapted):

I usually either use "delete" or "skip" for code-only answers in the VLQQ. From a curation standpoint these answers are useless.

Overall code-only answers are big signal that SO shouldn't want to send in my opinion.

I understand that there is users, who are not good with formulating explanatory text.1 But I think the "damage" done by enabling no-effort users and at best mediocre answers is higher than the damage from explicitly putting such answers up nuking cleanup.

Am I assessing this situation wrongly, or should we start curating such answers more aggressively (by editing or even deleting)?

19
  • The latest example of a new reviewer not agreeing with the code-only policy: meta.stackoverflow.com/questions/311076/delete-low-quality-post
    – Vogel612
    Commented Nov 25, 2015 at 10:07
  • 3
    So why am I bringing this up? - Really, why? How your discussion does differ from ones you link, e,g, from this one? If you have your opinion on existed topic, just post it to corresponding topic. Experience of Code Review user would be useful there.
    – Tsyvarev
    Commented Nov 25, 2015 at 11:17
  • 1
    @Tsyvarev Because these meta-posts are fragmented. Also I do not challenge the validity of the answers given at that time, but the policy as of now. Or rather: I don't challenge the policy (yet) but I'd like to discuss this in the light of these policies.
    – Vogel612
    Commented Nov 25, 2015 at 11:35
  • So, you want to introduce some soft policy, not concerned with voting-to-close or downvoting. Is my understanding correct? If so, it may be good topic. But your post told about deleting, which is already discussed on meta...
    – Tsyvarev
    Commented Nov 25, 2015 at 11:44
  • 1
    Its too specific a "problem" for me. Yes plenty of code-only answers are of the horrendous kind, but so are just as many answers which contain no code at all; its still people posting sucky answers; no need to be specific. In certain tags, I dare say javascript related tags as an example, answers with only a snippet of code can be the "a picture says more than a thousand words" kind of deal. If you waste words on it, you just spoil the moment.
    – Gimby
    Commented Nov 25, 2015 at 16:13
  • 2
    I'm all for code-only responses, only because there are plenty of times where someone is just using the wrong function etc., and they clearly just want to see how to write it properly or you know they will understand it simply by seeing the code. If they want it explained further, they can always comment and ask for further explanation. If they do ask for further explanation and the answerer doesn't give it, then by all means downvote the answer. Commented Nov 25, 2015 at 21:35
  • 2
    @AaronD well, you're a minority in that. What is the harm in explaining "You're using method X, which does X, while it seems like you need method Y, doing Y"? It helps not only OP understand what they did wrong (as opposed to them copy-pasting your answer and learning nothing), but also later visitors to quickly assess whether the answer applies to them. Remember, we're not here for the OP. OP getting their question answered is a side-effect; this is not a forum.
    – CodeCaster
    Commented Nov 26, 2015 at 8:10
  • 2
    You may be overthinking the issue. Was the code-only answer correct, helpful, and useful, as evidenced by upvotes and being marked as the accepted answer? If yes, leave it alone or curate it by improving it, don't delete it. Don't delete correct, helpful answers on a technicality and call it "curating".
    – aroth
    Commented Nov 26, 2015 at 11:56
  • 3
    I'm wary of the fish-related rhetoric that this question uses (and which is common on Meta). A fish can only be eaten by one person, but a code snippet can be used by many. If the question-asker is asking for code to solve a problem that lots of people have, the answer will be of use to all those people when they see it even if it has zero explanation. I do not have a witty fish-related metaphor for this scenario, which probably indicates that there are some ways in which blocks of code are not the same thing as fish.
    – Mark Amery
    Commented Nov 26, 2015 at 12:01
  • 2
    Don't forget Give a man to fish, feed it for like four weeks. Commented Nov 26, 2015 at 13:07
  • 3
    Showing a million people a picture of a fishing rod doesn't teach them how to fish. Explaining what the fishing rod does - and illustrating it with a picture - might.
    – Sobrique
    Commented Nov 26, 2015 at 14:44
  • 2
    I don't fully agree with "People getting free fish, not getting a fishing rod and a fishing tutorial". It's not SO's job to teach people how to program and answers shouldn't be tutorials. The web has plenty tutorials. We cater to people who have a fishing rod, know the basics of how to fish, and then find a fish they couldn't catch and want to know the finer points of fishing.
    – MicroVirus
    Commented Nov 26, 2015 at 14:48
  • 1
    So much talk about fish...but how exactly is code the same as a fish, again? I mean, especially if it's commented and/or self-documenting code. Fish don't come with built-in instructions on how fish work (unless you can read DNA; and even that only works so long as you don't cook/eat the fish). Good/commented code does. In plain English no less; no DNA sequencing needed.
    – aroth
    Commented Nov 26, 2015 at 15:46
  • 1
    One important point to remember is that a Stack Overflow answer is not just for the OP to learn from - it's for every Stack Overflow user, present and future, who might have a similar question later on. Don't think in terms of teaching a man to fish - open a fishing college and feed an entire village forever. Commented Nov 28, 2015 at 7:43
  • 2
    Possible duplicate of Can code-only answers be high quality? Commented Nov 30, 2015 at 13:33

7 Answers 7

20

I tend to think repeatedly, "look to the questions, not the answers."

If someone asks a question like:

I've been unable to turn on the computer. I've tried opening it, looking inside at things I don't understand. A google search on the topic didn't reveal any insight. I tried cleaning the case and making it shiny. I tried pushing the on button twice in a row really quickly, still no avail. I've been trying to study electrical engineering to help me understand what is going on, but as of yet, I've been unable to turn on this computer for the past 6 months. I'm running out of ideas. Does anyone have any suggested steps to help me diagnose or solve my problem?

... and the best answer could be,

Try plugging the cord you see in the back to an electrical socket.

That could be the precise solution, and the one that gets all the up-votes.

Even though that's not a code-only answer, I see it as pretty much the same thing. It's terse, straight-to-the-point, has little educational value beyond providing the author of the question with an immediate answer. It provides the free fish.

The extreme opposite kind of fishing rod in this case might end up going into how electricity works, starting with a history revolving around Benjamin Franklin, and then healthy levels in between these two ends.

Yet that would hardly be the right place and time for someone to share his/her expertise on the matter in a way that would be exposed and educational for many others. It might even be seen as a poor answer to the question and down-voted to oblivion.

It's why I think the more we get closer to a fishing rod answer, the more it can only be effectively provided for a reasonably general question. "How do computers conduct electricity?" Now the experts have excuses to compose very detailed answers and even compete to provide the most accurate and detailed response, even going into a deep background covering topics like history. They start correcting each other on little inaccuracies and getting into really expert-territory discussions about the accuracy of their answers. These moments, albeit rare, are when SO starts to become outright magical, doing something few other community sites do.

The question might even be posed in the context of someone lazy and seeking a homework solution. The context matters little to me, the experts have already been given an excuse to compete to build the best fishing rod they can. What matters is that such a question can leave something behind that may catch the attention of many and educate a whole bunch of people.

SO's voting system is most effective when it's used for quality control in this kind of context, in a question where the quality of the answer is highly variable and not chiseled down to a binary "is it correct or not?" kind of answer based on the narrow applicability of the question.

But a troubleshooting question often wants a fast answer. Those are so narrowly chiseled down to a black and white, "Did the answer solve the problem or did it not? If yes, how quickly was it provided?" That becomes the "quality" metric in those troubleshooting scenarios: speed.

So I really think the problem is the question. I don't think it's very effective to try to curate answers providing terse or code-only answers. Sometimes they are the "best" answer as most would judge based on the context of the question. The question sets the stage. So I really think if we want to even find more incentives to provide fishing rods, we need to encourage questions that seek those kinds of answers.

8
  • 7
    Insert Hearty Applause Here
    – skrrgwasme
    Commented Nov 25, 2015 at 21:35
  • 3
    I'd have gone for "Try pressing the ON button a single time!" :-)
    – Bergi
    Commented Nov 26, 2015 at 4:25
  • 6
    Bit of a false dichotomy in this answer. I think there's a happy medium between "Try plugging the cord you see in the back to an electrical socket" and "here's the history of electricity starting with Benjamin Franklin". How about "Computers require electricity to run, like the other devices in your home. If the power cable is not plugged in to the computer, then it will not be able to draw the power it needs. Try plugging the cable in - the computer will then be able to draw power and you should be able to turn it on. In the future, always check the power cable if it won't turn on"? Commented Nov 26, 2015 at 12:05
  • @RichardIrons That's true -- I must admit I was pitting extremes against each other for an exaggerated effect. But some of the most interesting Q&As on this site sometimes do reach that level of educational appeal -- it depends on the question to trigger it as I see it.
    – user4842163
    Commented Nov 26, 2015 at 12:06
  • 1
    In general I think everything breaks down to a spectrum, not a dichotomy. I have a tendency to communicate in a way where I try to establish the polar ends, but one of the things I often forget is to explicitly say that these are polar ends, and that the ideal isn't necessarily in the extremes, but often somewhere in the middle. It's a poor habit of mine when I communicate -- I like to point out the polar opposites.
    – user4842163
    Commented Nov 26, 2015 at 12:10
  • 1
    @RichardIrons I updated the answer to try to suggest it doesn't break down into simple black and white between a narrowly-applicable answer and an overtly general one, that the healthiest balance it most likely somewhere in between, along with questions that make room to trigger something in the middle.
    – user4842163
    Commented Nov 26, 2015 at 12:13
  • 1
    Cool, yeah that makes sense. In general I like to assume that when someone has a problem that's due to having a faulty strategy in the first place, and they ask a rubbish question because of this, they'll still be receptive to being helped to come to the right strategy, and maybe that will help them more in the future. Commented Nov 26, 2015 at 12:16
  • Those are unfortunately the worst IMO -- the X/Y kind of troubleshooting question. It's also awkward to me when, say, the title totally misdiagnoses the problem, but gets a very reasonable answer that's likely to be overlooked because of the misdiagnosis. I always find it awkward because to edit the question might be way too intrusive to the author, but keeping it as it is would probably make the whole link get overlooked by people having the same issue.
    – user4842163
    Commented Nov 26, 2015 at 12:18
22

Like @Hans addresses, most interesting questions simply have already been asked. So whether we want and realize it or not, Stack Overflow is the biggest live debugger in the world.

Almost any question that gets posted nowadays is based on a false premise or XY problem ("[optional: I want to do X,] I need to do so[mething] using Y - but that doesn't work, help"), or is an implementation mistake ("I'm getting a compiler error / runtime exception"). Or even worse, it's simply "I want to do X, give me teh codez".

Given the "pessimists" (down- and closevoters) are by far not getting enough traction to downvote, let alone close these questions, they're getting answered - helping OP alone, as those questions are often too localized.

Given those premises, the questions that years ago would be "too localized" stay open and visible for everyone, so you can answer those questions. And in the illustrated cases, you can do so easily with code alone.

As I already wrote here in comments and my answer in "What should a minimal answer contain?": an answer that is missing an explanation, does not show me that the answerer understood the problem.

It is not that hard to type "You're doing X, you should be doing Y", or "You were missing a Z", or "One option is to do that using Q".

Contrarily, what do you expect the later reader of a "try this" or code-only answer to do? Put OP's code and the code from the answer in their favorite diff tool? How will you figure out what algorithm the code is implementing? How will you see that the implementation contains an error (and no, those are not downvoted)?

So I say: unless the problem is extremely trivial and the solution is extremely clear from the code given and the code is correct, downvote any answer that only contains code.

12
  • 7
    they're getting answered - helping OP alone, as those questions are often too localized. - I don't think code-only answers help the OP alone. Answers like Use yourString.charAt(0)=='A') are perfectly valid *code-only answers to questions like Java - how to find whether the first letter of a String is 'A'?. We don't have to explain the OP what charAt() does. We don't have to explain what it does to people looking for Java- how to get the first character of a String and compare it to X right? Commented Nov 26, 2015 at 4:53
  • 5
    "Given the "pessimists" (down- and closevoters) are by far not getting enough traction to downvote" -- oh boy, you can sure say that again. And it's not just the lack of downvote traction, it's the surprising (shocking, even) amount of upvote traction that happens. The vast majority of questions, even answerable ones, often get at most 1 or 2 up-votes, so how does a question like this one get five? Commented Nov 26, 2015 at 7:57
  • @Peter because "ooh cool, you're making a game". Or so, I really don't get it.
    – CodeCaster
    Commented Nov 26, 2015 at 8:00
  • 1
    @CodeCaster - Such a question is a duplicate anyway - Agreed. But that doesn't make the answer wrong. Newbies often tend to answer such questions and personally I don't downvote them for that. Its not fair. I agree code-only answers should be discouraged in most tags / cases but in tags like regex, I don't think you need to add a whole lot of stuff explaining what \\w+ does and what () does. There are some (really few) cases where code-only answers are OK Commented Nov 26, 2015 at 8:21
  • 8
    @Vinod so you're saying we should let the site's quality degrade, just to be nice to newbies? A crap answer is a crap answer, whether posted by a 1 rep or a 100K rep user. As for your regex example, there are sites that can generate nice schemas of how a certain regex works. Dumping just a regex, again, helps nobody.
    – CodeCaster
    Commented Nov 26, 2015 at 8:28
  • 2
    @CodeCaster - I am not saying that we should let the site's quality degrade. I do support being a little nice to newbies though :P. Code-only answers are not crap answers;not always. The term sufficient explanation lacks an authoritative definition. I agree a code-dump would be useless in most cases but in some cases, it is OK if the code explains what is to be done. You honestly can't expect each answer that uses regex to put schemas in there. SO doesn't work that way. The early bird gets the worn in 99 percent cases. Commented Nov 26, 2015 at 8:40
  • @CodeCaster - This is what I am also stressing on. You can't stop bad questions or dupes :( Commented Nov 26, 2015 at 9:01
  • @Vinod thanks for that explanation. Note that this is a discussion question. I can only accept what you say as the truth, but I don't agree that what you say is the way it should be. Hence my stance. :)
    – CodeCaster
    Commented Nov 26, 2015 at 9:12
  • @CodeCaster - I am not saying that this is the way it should be. I am merely saying this is how it is as of now. We will have to live with it :). But yes, we will have to slowly educate the people on SO on how to deal with these things. Commented Nov 26, 2015 at 9:17
  • 1
    In my opinion, not only "sufficient explanation", even "extremely trivial" lacks a clear definition, someone may argue that your "extremely trivial" is different from mine.
    – ggrr
    Commented Nov 26, 2015 at 9:37
  • I often find that a question is analogous to "How do I tie a reef knot?", and when you read the question text it turns out the OP is trying to build a wall by tying bricks together with string. Then there will be some comments on the question saying "possible duplicate: [some other question about reef knots]", and then more comments and a couple of answers simply with varying ways tie a knot. I think these questions should be answered with "you oughtn't to build a wall like that; here's how to do it with mortar". It's the "teach a man to fish" philosophy. Give the learner some mentorship. Commented Nov 26, 2015 at 12:09
  • I think new technologies appear just as fast or faster than how fast we cover possible issues here on SO. Commented Nov 26, 2015 at 13:06
6

There are no black or white cases. You can't say that all code-only answers are bad by default.

  • First of all, the fundamental difference between SO and Code Review is that questions on SO are usually of the kind "How do I...?" or "How do I fix...?" and a number of other variations. While Code Review questions are always "How do I improve...?" with no exceptions.

    A pure code answer can in some cases answer the "How do I do/fix" questions to 100%, particularly if they are simple questions. Though most of the time, pure code answers are not good, particularly not to more advanced questions.

    But dumping a pure code answer with no rationale given on someone who wish to improve their program is simply never helpful. Particularly not since lots of answers on Code Review involve coding style, which tends to be subjective.

  • This doesn't necessarily have anything to do with the problem of code begging: the OP could have posted a nice example to re-create the problem and the solution might be something so simple that no explanation is needed, just a few lines of self-explaining code.

  • Everyone who snaps at every single code-only answer should perhaps stop and consider how they write code themselves. For example a C code line:

    x = y & 0x03C0 + f(123);
    

    is poor, unreadable and therefore needs plenty of comments, while some line like:

    checksum = read_val & ADC_RESULT_MASK + calc_offset(FIXED_OFFSET);
    

    is self-documenting to anyone familiar with what the algorithm is doing.

    It is actually quite possible to write code-only answers that are much clearer and easier to understand than some textual ones, even though those would be a rare cases.

    Also, keep in mind that a "code-only" answer which contains a generous amount of comments isn't really "code-only".

6
  • 2
    "It is actually quite possible to write code-only answers that are much clearer and easier to understand than some textual ones" - sure, but that is not what I'm going on about in my answer. It is also very easy to add the introductory text "You need to call calc_offset() to calculate the offset" to the same code-only answer. It explains the why, instead of just showing the how. Code-only promotes cargo cult programming; text promotes understanding and enables further research.
    – CodeCaster
    Commented Nov 26, 2015 at 15:17
  • 1
    And yeah, in this example that may be obvious from the function name, but by not explaining that you need to calculate the offset, some later reader may assume that it is required when in reality it is not. Again, if you want to write code as an answer, I want you to explain it, so other readers can assess that you know why you posted that code.
    – CodeCaster
    Commented Nov 26, 2015 at 15:18
  • 1
    @CodeCaster Well, that is a perfect example of a programmer shouldn't be doing... Most of the sentence "You need to call calc_offset() to calculate the offset" is superfluous fluff. The text added nothing of value, it is already obvious by the function name that the function does that, because the function name is self-documenting code. You sometimes find such useless comments like printf("hello world"); // prints "hello world" which is just bad, the comment added nothing but clutter to the code.
    – Lundin
    Commented Nov 26, 2015 at 15:25
  • 3
    I knew you were going to say that. First of all, it's not a "superfluous comment". Remember we're on a QA site where OP has a problem that the answerer is solving? It's very useful to explain what the answer does, before even showing code. You're not showing a question that that oneliner is an answer to. If the question points out that OP does not know an "offset" exists, and the answerer introduces that concept in code without explaining it, it is a bad answer that promotes copy-paste programming. By explaining what an offset is, and showing how to calculate it, everyone's better off.
    – CodeCaster
    Commented Nov 26, 2015 at 15:29
  • 2
    The same goes for, for example, the question "How can I increase a numeric variable" that gets solely i++ as an answer. It is an answer, and it is valid, but it does not explain anything. Is that the only way to do an increment? Is it the best way? In which situations is it? You could at least mention the term "post-increment", so OP can find out more by searching the web for that term. Anyway as usual we're having a very abstract discussion, which is getting useless answer. Most answers that are posted nowadays are not oneliners.
    – CodeCaster
    Commented Nov 26, 2015 at 15:31
  • Take this answer for example. No, you should not add such comments in production code, but on this site, it is very helpful just to demonstrate (using comments and text) what that code does.
    – CodeCaster
    Commented Nov 26, 2015 at 15:33
4

I see two questions here -

  1. Why allow people to answer to give me the codez questions.
  2. Why not delete / nuke code only answers.

Lets, take them up.

  1. Why allow people to answer to give me the codez questions.

Lets just face it. Every person who knows the answer to a question wants to answer it (OK. Not every person, but most of them :P). Each time this question pops up, we always have people trying to answer it. They are mostly newbies trying to get some rep on SO. Some of us try to close them ASAP but we can't do it always. People do this and honestly, its is not wrong. I personally answer regex questions (which show no effort) sometimes because they seem interesting and gives me practice. And remember our answers are not only limited to the OP's question, there might be some person somewhere who might have tried something to whom our answers might be helpful. Some questions get nuked because we find them before others do. Some don't. Yes, we need to ensure that give me the codez questions get nuked, but I don't think that it will work.

Next, we can have questions where the OP has a main() method and says - not able to read input from Scanner. What a person thinks as enough code to answer is relative and frankly we can't bring the mods into this because they are busy with lots of other things. We can try as hard as possible to prevent this, but I am not optimistic that it would work.

  1. Why not delete / nuke code only answers.

Many a times code-only answers are self-explanatory. For a person who understands regexes well, this answer of mine should not be difficult to understand (just giving an example). If the OP doesn't understand any part of a self-explanatory code, he / she can always google it or ask it in comments or as a new question.

I agree, for some answers, explanation should be made necessary, because the OP needs to know what he is doing wrong. So, for the above question, an answer which doesn't tell them what is wrong is not an answer and should be deleted. The same applies to comparing Strings with ==..

2
  • 8
    "self-explanatory code" does not exist, especially not when written on the internet by people whose experience is unknown to the reader. More often than not, code-only answers are a guess.
    – CodeCaster
    Commented Nov 25, 2015 at 14:50
  • 2
    @CodeCaster - Not always. Most code-only answers are for give me tho codez questions where the OP asks for - how to do this and shows us sample input and output. Simplest example could be, How to replace character X from abcXX String. Next minute, we will have a code-only answer. Commented Nov 26, 2015 at 4:46
2

I think Code Review differs because actually understanding ways to improve is the impetus of the site. Giving people better code without actually reviewing their code is not an answer because it doesn't at all solve the question of how to improve.

On Stack Overflow, the question is "how to do/fix X". If you post code that does or fixes X then even the original poster doesn't understand it, then you have answered. Answers are considered answers if they attempt to answer the question (even if it's poorly), so a code only question is a bad answer that's vague and unclear but it's still an answer.

Instead of flagging I usually opt to post a canned comment emphasising the value of explanations:

Please consider editing your post to add more explanation about what your code does and why it will solve the problem. An answer that mostly just contains code (even if it's working) usually wont help the OP to understand their problem.

1

My answers with explanation never get as much upvotes as those that just quickly post the working code.

Inversely, my code-only questions get much better reception than theoretical questions ("why", "how", "what if").

Therefore if the direction of SO is directed by it's community, it's safe to say that code-only questions are OK as long as the problem is something else than a typo.

3
  • 2
    Isn't that just because essentially the askers are asking "gimme da codez" and do not care about an explanation? And, realistically, does Stack Overflow want to be a "send your code and we will fix it" site?
    – Jongware
    Commented Nov 26, 2015 at 13:19
  • 1
    @Jongware What stackoverflow wants or wants not can only be guessed based on what people do and what they vote for. And I found out that poeple are indeed not interested in reading text and writing text, the main concern is code. When it comes to my elaborate answers and their low reception, I usually post these to 1 rep users who seem to need them. I do not expect to get upvotes from those users, but I expected others to support my effort. Commented Nov 26, 2015 at 13:22
  • And this applies to other's posts as well. I usually need to scroll down when I want explanation and not just the code when searching on SO. Commented Nov 26, 2015 at 13:22
1

Some of the advantages of code-only answers that I can think of:

  • Unlike the ambiguity present in human language, and the difficulty that many SO users experience in writing proper English, code was designed to be inherently unambiguous with a very small vocabulary. A code-only answer is therefore almost always superior to a text-only answer.
  • A questioner almost always prefers the day-fish. He's got a problem he wants to solve within the next ten minutes, the life-fish will have to wait until next week. Also the core reason why FGITW is not considered a problem.
  • Consequently, a code-only answer is much more likely to be accepted by the questioner. The gamification aspect is rarely ignored.
  • If you need text to explain a code answer then the code isn't as good as it can be. Some programmers even claim that code should not be commented for that reason.
  • Code-only answers are very easy to review. Either you subscribe to the "they are junk" view and you can instantly VTD without having to understand the answer. Or you immediately give up because you don't know the language well enough to improve or judge the quality of the code. Oddly, some reviewers consider this a problem instead of an advantage :)

Disadvantages of code-only answers:

  • They are often very, very boring to the set of users that read the answer within the next 24 hours. Who generally read Q+A to catch a new fish, not to solve the exact same problem the OP is having.

Actually the only disadvantage I can think of :) Creating a web site with a lot of boring content is not a great strategy to engage users and get them to spend time on the site. Without such users, the number of them that will answer questions is inevitably going to be lower.

So I think that's the guidance, should SO be entertaining or just be a site that collects Q+A useful to programmers that look for an answer to the same problem. The company leans pretty heavily towards the latter choice. I personally lean pretty heavily towards the former. But that's just because I spend too much time at SO, I like fish too much.


Fwiw, SO is not very entertaining lately. But I think that's because the questions are pretty boring and therefore attract boring answers. Like that meta post you linked, talked about a null reference exception question that didn't get a single close vote. Yawn. Ideally we can prevent such questions from entering the system. We can't, not anymore, there is no simple way to vote "this question is not good enough, it doesn't belong here". Thus producing a lot of answers that don't belong here. Addressing that problem is a very different kettle of fish.

14
  • 4
    "is:a try this code": 21,109 results.
    – Jongware
    Commented Nov 25, 2015 at 12:33
  • 2
    Out of 17 million answers, a 0.12% problem. Surely you can find more bad answers? Well, not with a quicky query. Commented Nov 25, 2015 at 12:37
  • 16
    Code (no matter how well written) can only explain what happens, not why to get from the why to the what is significantly easier than the other way round. As such I can't agree with the statement that 'a code only answer is always better than a text only answer'. Also I'm not sure how the benefits you list are beneficial to 'making the internet a better place'
    – Vogel612
    Commented Nov 25, 2015 at 12:45
  • 4
    As noted, the questioner almost always only cares about the what and doesn't give a hoot about the why. Only fishermen like you and me care about the why. Go back to that NRE question, is there anybody that even got close to explaining the why? Was there a point in singling out only that one answer? Would anybody take the time to write the why answer when it has been done so many times before? As long as we don't close such a question, the what answer is the only reasonable expectation. Commented Nov 25, 2015 at 13:04
  • 1
    Building off your day fish analogy, it's often better to give a person a fish so they don't starve and then spend the next day teaching them to fish. Aka answer and then edit/update.
    – ryanyuyu
    Commented Nov 25, 2015 at 13:41
  • 7
    A "try this" or code-only answer is not a good answer, because it does not tell me that the answerer understood OP's problem. While for the most trivial problems a code-only answer will suffice, for any ambiguous (or dare I say: unclear) problem, I expect an answerer to explain their reasoning. It is not that hard to introduce your code with "You're fooing the bar, you need to quz the baz instead:". If an answerer cannot do that, they either didn't understand the problem, or don't understand the code they're posting (copy-pasting).
    – CodeCaster
    Commented Nov 25, 2015 at 14:55
  • 1
    Or they didn't think the question was important enough to merit an explanation. Like that NRE question. Kinda sucks that I have to keep playing the devil's advocate btw, I certainly never post an answer like that myself. Behind many a bad answer there's a lousy poorly researched question. Deleting the incomplete answers but not the bad question makes little sense. Commented Nov 25, 2015 at 15:17
  • 1
    I do understand you're "throwing the bat into the chicken coop" (rocking the boat), and I do think such questions should be closed in the first place. Maybe the underlying question is "How can we prevent uninteresting questions to be posted?", followed by "How can we prevent users from answering uninteresting questions but letting them vote to close instead?".
    – CodeCaster
    Commented Nov 25, 2015 at 15:26
  • 11
    @CodeCaster, how can we prevent users from answering uninteresting questions but letting them vote to close instead? We can't. It's too late. Users now routinely answer crap questions, upvote those questions in the process, upvote their answers among themselves, and stand up to anyone trying to convey the idea that bad questions should be closed and not answered. I'm starting to believe there is nothing we can do about it anymore. Commented Nov 25, 2015 at 15:29
  • @HansPassant: perhaps a SEDE query to browse for code-only answers is possible.
    – Jongware
    Commented Nov 25, 2015 at 16:49
  • 2
    It is wrong to expect that every person who asks a question on SO is here to get an explanation of what happens. And I've personally seen people ask can you please explain this... in case they don't understand the code. Interestingly, there are hardly few places / tags where you can have valid code-only answers. Down-voting code-only answers is wrong because they aren't technically incorrect. Even if we decided to down-vote such answers, the next question which would come up is - what is considered as sufficient explanation?. How can we sort that out? Commented Nov 26, 2015 at 8:31
  • 2
    The fact that a question's OP might just want a quick answer shouldn't discourage us from giving better ones. A lot of other people will probably find the answer, and those people might actually be looking to educate themselves. The questions and answers are public for a reason. Commented Nov 26, 2015 at 12:12
  • 1
    You can downvote for 'not useful' as well - and I would assert that code-only could count as such, because of their lack of explanation. (much like 'link only' would).
    – Sobrique
    Commented Nov 26, 2015 at 14:43
  • 4
    I recently had a user who actually considered their code-only answer superior to my code-supplemented-with-an-explanation answer because they considered explanations to be "chit chat" (as quoted from the tour page) - in other words, noise, not useful, detracting from the core answer, etc. Go figure.
    – BoltClock
    Commented Nov 26, 2015 at 15:02

You must log in to answer this question.

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