-12

From my experience, answers on this site that are literally just code don't really help all that much except for solving that specific problem. It is important that especially new users to programming get an explanation about what the solution is actually trying to do instead of just the specific solution to their problem.

I feel like SO isn't just a Q/A site, but a place that users can use to expand their coding knowledge/experience and straight code answers don't help this at all.

10
  • 16
    Because people treat it like a help desk.
    – Kevin B
    Commented Feb 7, 2023 at 16:20
  • 2
    @KevinB yes, but answers should actually explain what went wrong with the OP's solution and what to do to fix it, not just a straight copy paste about how to solve the problem. Commented Feb 7, 2023 at 16:23
  • 10
    There's a simple "solution" to if you find an answer like this, and because it contains no explanation it's not useful/helpful to you; downvote it.
    – Thom A
    Commented Feb 7, 2023 at 16:23
  • 1
    I don't disagree, however, you asked why people do it, not what people should be doing, ;)
    – Kevin B
    Commented Feb 7, 2023 at 16:23
  • 4
    I'm not entirely sure how you expect us to respond to this. Are you hoping that people who do this will speak up and face the criticism? I think you will find pretty wide agreement that answers shouldn't be like that. Commented Feb 7, 2023 at 16:24
  • 5
    I just downvote answers like this. Unless the code is simple enough that I can understand what it's trying to show me without words, then the answer is completely unclear.
    – Dharman Mod
    Commented Feb 7, 2023 at 16:40
  • 2
    You ask 'why'. I suspect that one reason for code-only answers is lack of fluency in English. In effect, people who aren't confident in their English are communicating through code. Commented Feb 8, 2023 at 0:11
  • People need to suck up the 1 rep cost of downvoting and get to work. Commented Feb 8, 2023 at 0:37
  • 1
    Pretty much the same people that leave a review on Steam like "This game is garbage". The grace us with their presence, but don't linger long enough for us to appreciate it. There is no point to try and reason why, that just leads to name calling and finger pointing. Code-only answers are against the rules, there is little more to be said about it than that.
    – Gimby
    Commented Feb 8, 2023 at 9:21
  • Cross site: "That's not what Stack Exchange is for! Explanation is vital for a good answer." Commented Feb 9, 2023 at 3:40

2 Answers 2

12

Answers should absolutely contain an explanation of how the code they are providing solves the problem.

It is important that especially new users to programming get an explanation about what the solution is actually trying to do instead of just the specific solution to their problem.

It's not even about new users, all future visitors need some form of explanation to improve their ability to determine whether or not a given answer is relevant to their problem. A code dump may very well work for the OP because it's being provided for their specific scenario, it's very unlikely for future visitors with the same problem to be in an identical scenario.

I suspect the cause of this is answerers tend to want to help the OP because that's where the up front gamification of this site exists. It's not clear immediately that when you answer a question well it'll gain upvotes for years, compared to earning that accept vote on day one.

2
  • 1
    When looking for an answer to help myself, I prefer the ones with explanation. I'm a long time user and I've been programming for longer than I've been a user. That doesn't mean I know everything. The very reason I'm looking for an answer is because I don't know how to do something. Some code might help but I'd rather know how and why is a particular thing used. Otherwise somebody might have just written "You need to close your door - just use a hammer"
    – VLAZ
    Commented Feb 7, 2023 at 16:32
  • 4
    Of course, there's also the counter-point that the majority of questions are so specific/poorly presented that there's effectively 0 chance your amazing answer will even be seen by anyone else ever again. ¯\_(ツ)_/¯
    – Kevin B
    Commented Feb 7, 2023 at 16:38
3

From my experience, answers on this site that are literally just code don't really help all that much except for solving that specific problem.

This is a nuance in in Q&A that is overlooked in that, the basic contract of Q&A is someone receiving an answer for asking a question.

So I'm going to tell you something that's highly controversial.

A code-only answer is still an answer. With that, the expectation of Q&A is met and the person who asked their question may be satisfied with the answer.


Now I'm going to pull that back a bit since it's obvious that we do prefer answers that offer more of an explanation rather than someone just putting their code here and saying, "here, try this".

A code-only answer is still an answer. It's just not a very good answer by Stack Overflow's standards.


In that event, I prefer to just downvote those kinds of answers. They're not really helpful, so there's no reason to presume any circumstance of hurt feelings by indicating that their quality isn't up to par.

...but I want to be clear, they're still answers. You can't get mad at someone for literally doing what they were asked.

3
  • 1
    What if there was some sort of system in place where an accepted answer that receives a lot of downvotes automatically gets its accepted status removed and the poster gets the 15 reputation associated with it revoked. This would discourage answers like this that only answer that specific question. Commented Feb 7, 2023 at 17:19
  • 1
    @EpicPuppy613: Nope, since you're conflating two very separate things - answer quality and whether or not the OP said the answer worked for them. Ultimately we are the main force that determines and enforces the quality of posts on the site, and the tools we have are those up and down arrows on every post. Use them judiciously.
    – Makoto
    Commented Feb 7, 2023 at 17:32
  • 1
    @Alexei Levenkov: Re "code only answers are very likely to be correct": We need more data. I suspect many late (years later) code-only answers are plagiarised (they don't have any idea if it is correct or not; it might simply be search results blindly copied into the answer box) and/or completely bogus, but I might be completely wrong. Spot checking suggests they are, but it may be biased in various ways. Commented Feb 9, 2023 at 3:44

You must log in to answer this question.

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