Since we emptied the giant LQ backlog, I've been given the TSA screener treatment a few times. Which is to say, I've been presented with an answer, asked to react to it, and then told that:

  • it was a test
  • I got the test wrong

In two cases, the answer in question was a perfectly correct, perfectly responsive answer that just so happened to be 100% python code. I said, 'looks good.'

Now, I can imagine that some people don't like code-only answers. By no stretch of the imagination, however, can I see how they deserve to be deleted. People who don't like them might downvote them. But delete?

It seems to me these test questions need to be human-selected. And if these examples were, in fact, human-selected, I'd like to have a few words with the human in question.

I'm not sure, based on the answers, that everyone followed my 'TSA screener' joke.

Airport X-ray machines periodically pop up fake images to test if the screener is paying attention. The 'we already know the answer' review interaction is just the same thing.

I'm not arguing that code-only answers are wonderful. I have no quarrel with people who want to downvote them. I object to being hectored and browbeaten to click 'I understand' when I declined to recommend deletion for one of them.

  • 5
    It's easier if you just assimilate. Hurts for a bit, but then you don't have to think about it too much anymore. Commented Sep 13, 2012 at 0:44
  • 3
    +1. this is a q/a site, which means it is a place for people to ask QUESTIONS and get ANSWERS. In many many cases, answers that only have code in them accomplish the goal of an answer, which is to answer (or help answer) the question. The SOLE exception to this rule is the questionable homework tag; these should NEVER be answered in pure-code because policy/general rule is to help people do their homework but NEVER to their homework for them. Commented Sep 13, 2012 at 0:48
  • @tehdoommarine: we have a policy about what type of answers you can provide for questions people "think" are homework questions? You can give them all the code you want (or don't want).
    – user7116
    Commented Sep 13, 2012 at 1:02
  • 5
    @tehdoommarine - homework tagged questions should not be treated any differently from other questions - OP should abide by the same rules as the rest of us e.g. what did they try, legibility etc. If someone wants to give a well documented fully working solution to a "homework" question then they should be free to do so without fear of scorn and negativity. Half/incomplete answers to "homework" questions aren't answers and just frustrate both the OP and others (non-students) who may actually find the need for the same solution in their professional working capacity.
    – Kev
    Commented Sep 13, 2012 at 2:16
  • 1
    @Kev - this is why the homework tag is indeed questionable. here's a sample of what i mean by the homework questions (comments): stackoverflow.com/questions/12389670/… Commented Sep 13, 2012 at 3:40
  • @tehdoommarine: I fixed the question by removing the homework tag. See, now you can answer it! (...or vote to delete)
    – user7116
    Commented Sep 13, 2012 at 14:39
  • See also: meta.stackexchange.com/q/146790/186397
    – Drise
    Commented Sep 13, 2012 at 17:19
  • So there is a "TSA screener test" equivalent built in? Do you have a reference for that?
    – slhck
    Commented Sep 13, 2012 at 18:26
  • This suit is black not
    – bobobobo
    Commented Sep 13, 2012 at 19:00
  • 1
    @slhck is has been discussed here. I don't have a link at hand.
    – Rosinante
    Commented Sep 13, 2012 at 20:50
  • @slhck Here and this duplicate I answered before it was marked as a duplicate.
    – Mark Hurd
    Commented Sep 14, 2012 at 3:48
  • @tehdoommarine: Pure code answers are only valid answers to the question "what is the code to do X?" which is not a good question for this site. A good question warrants explanatory prose answers, often enhanced by examples in code. Commented Sep 18, 2012 at 17:33

5 Answers 5


Early on, we had an unfortunate bug in the quality-check algorithm that resulted in a lot of code-only answers ending up in the queue (and in some cases, deleted). This has since been tweaked, so you should see fewer of these... But very short answers will still tend to end up in the queue, particularly if they're all-code or link-heavy; evaluate these on their merits.

When you come across bogus tests, post examples. We can - and should -tweak our selection algorithms.

Also, if you come across an answer that shouldn't have been deleted (in the review queue or anywhere else), flag for moderator attention and note this.

  • 2
    In the queue doesn't exercise me. In the 'test queue' bothers me. The next time I'll capture it for you.
    – Rosinante
    Commented Sep 13, 2012 at 20:51

I have never seen a code-only answer that couldn't be made better with the addition of appropriate text. They are of lower-quality than the same answer with some text.

I agree that out-right deleting them is not the answer. It seems to me that what we need is a mechanism to say that we think a low-quality question can be improved, but isn't something that should be deleted.

  • +1 to marking it as "needing improvement". I was going to add that, but then I'd be way too long winded.
    – jmort253
    Commented Sep 13, 2012 at 2:05

It's true that code may answer the askers question. If code is posted that does answer the askers question, that's great, and that's awesome.... for the asker.

However, the goal of Stack Overflow is to be a resource of knowledge not just for the asker, but for future visitors for years to come.

Perhaps someone from Google may stumble upon the question and the corresponding answers. All things being equal, this person may have a slightly different problem or the scope of his or her problem may be different. Thus, all things being equal, even if this person has equal or greater skill as the original asker, this person will likely benefit from having an explanation posted under the code as well.

Considering that most of the activity on a post happens within minutes or hours of it being posted, someone coming from Google doesn't have the same advantages as the original asker. The asker, if confused by the code-only answer, can ask for clarification in the comments, and most of the time the person posting the answer -- or a passerby -- will clarify.

For those coming from Google, the original person who answered may not be around, and there may be few active people lurking around the page. Therefore, it's in everyone's best interests to post a summary under the code. This helps guarantee the answer is useful to future visitors, who just happen to outnumber the asker by a ratio of N to 1.

As an aside, since many people from Google may not have a Stack Overflow account, this could help reduce the number of comments posted as answers, which create more maintenance work for the community. What better way to eliminate "not an answer" flags than to prevent them from happening in the first place by posting thorough, detailed answers!

Fortunately, it's not hard to put in an explanation as an answerer, and the extra effort is more likely to result in more upvotes! If that didn't happen, if no summary was submitted, then the next best thing is for us to try to edit and add an explanation, if possible. If not, then the post has served its purpose by helping only the asker, and it should be deleted.

  • 5
    That's all true, but it doesn't mean code-only answers should be deleted. They can be more useful than no answer if left alone, and can also be edited to include explanation for the code. Not all of them, but many.
    – bfavaretto
    Commented Sep 13, 2012 at 3:02
  • Absolutely, @bfavaretto. If they can be edited, then by all means that should be the first step. But if the answer isn't helpful to future visitors and we can't figure out what it all means, then it's served its purpose and should be removed. :) Editing should always be the first consideration prior to deletion.
    – jmort253
    Commented Sep 13, 2012 at 3:16
  • 1
    I disagree. In many cases, questions of the form 'how do I do X in language Y' are best answered with exemplary code. When done well, it needs no text to make it a perfectly informative reference for future generations.
    – Rosinante
    Commented Sep 13, 2012 at 14:49
  • @Rosinante - Since it's not always easy to tell the difference, why not just be on the safe side and provide an explanation. It's much easier if everyone just plays by the rules.
    – jmort253
    Commented Sep 14, 2012 at 2:13

I haven't yet seen code-only answer that could not be improved by adding some explanatory text (have you?). As such, code-only answers are almost perfect candidates for downvoting:

Downvotes are the community's way of telling peers that their content can be improved...

But (and this is a very very big BUT), in support of your point, note that code-only answers are officially perfectly legal. Neither FAQ nor How To Answer give any indication that these are somehow prohibited.

For comparison, look at the strong discouragement given there to link-only answers - "provide context", "may be removed" - there's nothing like that for code-only answers.

The most negative evaluation I could squeeze from above references so far was clicking the adapted from link in "How To Answer", getting to Answering technical questions helpfully (note - this is not a part of SE network) and finding this statement somewhere in the middle, in a plain text, without any special emphasize:

Code without an explanation is rarely useful, however. At least provide a sentence or two to explain what's going on.

Summing up, all the authoritative references I've seen

have no trace that would even remotely hint

that deletion of code-only answers is encouraged - none, zilch, nada.

Because of above, I believe that suggesting deletion as a valid review option for code-only answers would be unfair. Decline to recommend deletion or choosing "Looks Good" for a code-only answer should be considered valid outcome in a test for stuff like this. If this is not the case, either test has to be redesigned / removed, or an authoritative reference should be provided to back up such an expectation in test.

For the sake of completeness, I personally agree that code-only is not a reason for deletion but that's not quite relevant here.

Side note. To me, the issue you describe also indicates a problem in review system design. I made a simple test to simulate actioning downvoting-candidate answer and I believe I figured what's wrong there.

  1. Review suggested me an answer that I decided to be worth downvoting, not deletion - just an action I mentioned as most likely appropriate for code-only answers.
  2. After some fussing with UI, I discovered a tiny link to an answer, clicked it (to open in a new browser tab) and downvoted - so far so good.
  3. After that, I returned to review window. It was showing me the same set of options - looks-good, edit, deletion, not-sure. Hm.
  4. I refreshed the window, my shiny new downvote was there, great. Now what about my options?
  5. Oops there are the same looks-good, edit, deletion, not-sure.

Hey! Hel-lo-o-o-o!! didn't I just actioned the item suggested for review?

Didn't I just put my own precious reputation where my mouth is? downvoting answers is not free, you 'know

Given that I downvoted, what of these freaking options suit me? None "looks good" now, every one sucks in its own way.


  • Think of the options in the perspective of the flag action - "looks good" would be "This looks good enough to not be flagged and handled", not "This looks good enough that it's perfect." Editing and deletion are results of flagging - downvoting isn't.
    – Grace Note StaffMod
    Commented Sep 13, 2012 at 16:27
  • @GraceNote agree. With this in mind, "Looks Good" option sounds quite valid to me. Though I'd rather remove such a test at all since it sends an ambiguous message. As you pointed, it could be interpreted differently, as if code-only is perfect - I am not quite comfortable with this
    – gnat
    Commented Sep 13, 2012 at 16:52
  • 2
    The last part of your answer makes me think of the many requests for having the ability to vote back to the LQ queue, without requiring us to follow the "link" link. I agree that voting is a valid action in review too.
    – bfavaretto
    Commented Sep 13, 2012 at 17:23

I agree though in the sense that it is truly an informative code-only answer.

If the code is readable such that no further explanation is given/needed/required, I don't think it should be deleted.

But if I am presented with code that looks like spaghetti, unreadable yet answers the question, that is, the code works, I think it deserves a down-vote at the very least (as the tooltip says: This answer is not useful, where usefulness I am subjectively saying depends on readability as well)


  • don't delete informative code only answers - Up-vote them
  • don't delete non-informative code only answers - Down-vote them

Deleting should only be used for comments left as answers or spam.

Or when the original poster wants to remove their answer

  • 1
    If the code is readable to where you think no further explanation is needed, then that puts you in the perfect position to edit it with a brief explanation, and it's the easiest way to win the battle against the people who would love to delete it. :) If you can't beat 'em, join 'em.
    – jmort253
    Commented Sep 13, 2012 at 1:32
  • print("Hello world!") // prints "Hello world!". There's nothing more than I hate than unbelievably stupid practice I have seen in some schools, where teacher forced student to comment every trivial line with stuff like int speed; // declare variable to hold speed or speed += 20 // increase speed by 20. Many, I believe more than 50% of questions require very simple snippets of code in answer and if they're not transparent to someone without additional explanation, providing it is unlikely to help that person either. Commented Sep 13, 2012 at 12:54

You must log in to answer this question.

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