11

What should we do about answers that contain only code*? I include in this description answers where there is a token explanation that doesn't even come close to being comprehensive.

Here is an example: https://salesforce.stackexchange.com/questions/138264/trigger-is-not-performing-well

When I see answers that contain only code, I am strongly tempted to downvote and flag them. They are just not useful to the community. Maybe they will help the OP implement something, but likely they will not even help the original asker better understand the platform.

  • Should we delete these posts?
  • Can we come up with a comment template to prod users to better answer that touches on the above?
  • Is it really fair to downvote a code dump answer? I can't say I've read through them in their entirety to determine the code quality.

* I will try to find some references in the Help Center for why this behavior is inappropriate if I can.

10

To be fair, I have personally answered questions with so-called code dumps. However, I generally include copious amounts of comments (usually about one comment per line of code). I feel that this generally allows future visitors to completely understand what's going on with the code. I generally use this format when the question's code requires severe modification in order to be logically correct, rather than try to explain all of the problems, or when I feel an answer's code could be self-explanatory without any additional supporting paragraphs. As long as the answers include sufficient explanation, be it by comments or by prose, I'm okay with code dumps. Otherwise, as noted in the other answers, we should ask for more explanation via comments.

  • 1
    Yes, but your code dump answer are the paragon of how to "dump" code, and you do include explanation, it's just in the comments instead of the post body. I appreciate that posting format, and it's an obvious exception that I would never flag as low quality. That said, given user12345, inclusion of comments is not a reliable indicator that the quality is, indeed, sufficient. – Adrian Larson Aug 26 '16 at 18:01
7

I do not think the post should be deleted. An answer is still an answer, and even if it's just code it still may help OP.

I agree that ideally an answer should be well thought out, have good explanations of the code, and help the OP better understand the platform. However not everything is ideal.

My suggestion would be to encourage the person who posted the answer to give a better explanation of what the code does. Or even provide an answer of your own with code and well thought out explanations.


Possible Comment Template:

Can you please provide some explanation for the code you've written so we can better understand how it works?

Can you please provide some explanation for the code you've written so we can better understand how it solves the problem?

  • Any thoughts on a good template to use for such comments? – Adrian Larson Aug 25 '16 at 16:14
  • 4
    @AdrianLarson I've updated my answer to include potential templates to use. – dBeltowski Aug 25 '16 at 17:18
  • 1
    I would suggest prefacing what you've written with Please take the time to visit the [Help] and read [How do I ask a good question] (http://salesforce.stackexchange.com/help/how-to-ask). Or follow it with For more, visit [Help] ... – crmprogdev Aug 27 '16 at 13:18
4

I agree with your sentiment that a straight code dump doesn't provide much value to the community (or for people incoming from a good googling).

At best, it solves one, usually very specific use case. Unless someone has a decent amount of experience and spends an amount of time digesting the code dump, it's unlikely that they will be able to apply it to their own situation.

Further, I agree that it is harder to glean better understanding of the platform from code dumps if for no other reason than people are likely to try to simply copy/paste the dump.

As such, I'd be fine with downvoting code dumps. Teach a man to fish and whatnot.

If the user who made the code dump comes back and adds sufficient explanation, the downvote can be undone (provided that they also comment @you so you remember to get back to the question). I find myself using a similar downvote policy for people who don't include enough details in their question.

4

The problem with the code dump answers is usually the question. So many people come on here without a clue about salesforce development and all they want is code that works. There doesn't seem to be any desire to understand the problem, to then be able to ask a quality question that is then useful for the community.

The question linked in the OP here is a really good example. The question doesn't show any understanding about what parts of their code works, and what parts don't. There's no examples of expected behaviour, or what part of it is incorrect. There is just a business requirement.

We should be encouraging people to ask better questions, so I'd like to see the question closed as unclear.

I don't really like the idea of downvoting the answers. It really discourages people to get involved, and could result in a bit of an elitist attitude on here.

2

I don't like to straight-up delete these as sometimes (if it's short) it can be enough. That said, most of the time I'd still downvote and/or add a comment. I'd rather train users to be better contributors than to accidentally drive them away altogether.

Of course, if they only ever post dumps then it's definitely appropriate to take a harder line.

1

There are plenty of situations where there's no much room for explanation . The person just misses to close a parenthesis or really trivial stuff. But I have to agree that the more complex a question gets, the more important it is to include additional information, not only for the user who asked the question, but for every person in the future that may also find that post useful.

You can distinguish clearly 2 kinds of people, those who came here just to solve their problem, and those who really care about the community and want to learn and help others to learn. Either when you ask a question or answering one you can act by those 2 ways. I think deleting those post may be excessive, but down voting an answer that doesn't provide explanation or comments and doesn't try even to explain to the user where the mistake was or what was he missing I think it's completely fine.

You must log in to answer this question.

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