Is it bad practice to answer a question saying:
Try this in your code:
//example code here
I have been downvoted sometimes; the last time was in this answer.
This time the person at least leave their comment saying why, and was for the
It’s preferable to explain why you want the asker to try that and what you changed. Throwing code on people doesn’t always help, and it can be hard to translate to other situations if someone doesn’t know what’s going on.
This one may have been pretty self-explanatory, but yes, please add at least a sentence in general as a matter of good practice.
And yes, the downward spiral of comments is a bit much. Thanks for taking it to Meta.
Code-only answers are discouraged, because they contain no searchable content. They also don't explain why they should "try this", and we make an effort here to be a resource for knowledge. Posting a block of code with no other information isn't sharing knowledge - it's just offering copy/paste code.
It's important to remember when answering questions at StackExchange sites (especially at highly technical sites like StackOverflow) that the purpose of the site isn't mainly to solve the asker's immediate problem, but to build a knowledge base of information that is useful to other people in the future.
In my view, an answer isn't an answer unless the person posting it knows that it is a solution to the problem at hand. If the poster wants to help the user debug and diagnose, they should offer this advice in comments. If the answerer guesses or suspects that a particular recipe might cure the problem, they should again stick to comments or find another question to answer.
If someone posts an actual explanation, at some length, of the form, 'your symptoms are similar to problem X, and if you have problem X, the solution is definitely Y', I have some sympathy. But just throwing some code up there with 'try this'? Nope.
The question clearly asked about the OP in the role being a tester of some web applications and that he was disturbed by the auto-complete functionality of his browser, namely Safari.
This was obviously a browser usage-question but then it turned out it's not - but only after the OP did clarify (quite some many minutes later despite comments asking back earlier).
That can happen so also there can be downvotes just because the context of the question was not clear for someone (I mean nobody is free of that, right?) and then there downvotes were given under the impression that the wrong question is being answered.
Apart from that as others have already commented, it's always good to repeat what the understanding of the question was in your own words (so to repeat it), giving the solution (e.g. in form of code) and explaining why. Most answers didn't do that either.
The answer you wrote was likely downvoted not because you had the words "try this" in it, but because you didn't explain to the user why your code would work. Initially you simply dropped in an example of a form (albeit that had the correct attribute within it).
The answer that was Accepted was shorter, but it did simply highlight which attribute to use in the form ie "Here is your exact issue" and the OP can understand very quickly what he needs.
Round 2 eh? :P
I just wanted to chip in because I agreed with most people at the time of commenting on the question, that the downvote for "try this" was a bit harsh.
However after some thought, I remember votes are used for numerous things, including downvote on badly worded questions and answers to entice improvements, and up votes on good questions and answers to promote decent content. Of which everyone benefits from, when you think about the result of the aforementioned system.
I commented on that question there should be some consideration given to the fact "try this" is commonly used slang to be an offering of good standing, and not necessarily something offered on a test basis.
Therefore, as there are two options to think about - "is this slang and so an actual answer?" and "is this is a suggestion?" - it causes confusion and uncertainty, and Stack wants solid sure "Here's what you need it will work" answers. Thinking about it, so do I...
Which means it was correct to downvote in order to prompt for a better answer.
I suppose people, myself included, tend to stray to the nice side and this was a simple question and answer scenario so was fine on this occasion.
So I would agree that being precise (and eating the rule book) is needed to keep things on track. One should only answer if you know it answers the question, and therefore can comfortably say "this will fix it" - "this is your answer".
@hakre, I see your point now :) And good job this isn't medieval times, as this Meta discussion would instead have been the stocks...