18

Consider this recent question I attempted to help on.

The root cause of the problem is unclear, but the code was messy and may have contributed to the issue.

So as a step in resolving the OP's issue, I proposed a different, cleaner way of approaching the problem that I hoped would get him closer to finding a solution. To me, this seemed more helpful than just leaving a comment saying "there's not enough information to say with confidence what the problem is".

However, I was downvoted by someone with 12k rep and told that "answers" were strictly for answers.

Is this really the case?

I'm not worried about the -2 rep, so please don't misunderstand, it's an honest question about what is better for the OP or for the site: attempts to move the OP forward as much as possible or simply terse comments stating "insufficient details".

7
  • 5
    I think that's a good answer, as it helps to answer the problem. It is too long for a comment, which is a valid case for an answer.
    – hichris123
    Dec 30, 2013 at 22:51
  • 1
    I don't see why this wouldn't be an answer - I certainly don't see why it's a comment. Gut feeling is that you did the right thing with your answer.
    – Makoto
    Dec 30, 2013 at 22:54
  • 1
    That is basically my question. Technically, it may not meet the strict definition of an "answer", but the technical limitations/design decisions of SO prevent me from giving any sort of meaningful code-containing-feedback in comments. I just wanted to make sure helping people was favored over some sort of strict adherence of what is an answer.
    – jedwards
    Dec 30, 2013 at 22:54
  • 2
    Everything looks fine to me, not everyone will always agree with you, and a voting option allows them a downvote (albeit only once)
    – Jakub
    Dec 30, 2013 at 22:59
  • I don't think this is a duplicate, @gnat; that's "Should I solve the problem and point out other problems?" -- this is "Should I point out other problems without necessarily solving the problem?"
    – jscs
    Dec 31, 2013 at 6:50
  • @JoshCaswell agree, "your" duplicate looks like a better fit
    – gnat
    Dec 31, 2013 at 9:11
  • 1
    Related discussion can be found at How to flag an answer that does not answer the question?
    – jscs
    Dec 31, 2013 at 19:51

2 Answers 2

12

An answer is meant to provide a solution to a problem. The trick is identifying the actual problem which doesn't necessarily mean that the problem is the code; it might very well be the approach.

By providing a better approach to the same underlying problem you will have cleared up the problem and it will probably be very useful for future readers, which are the primary target of your answer anyway.

Even if the person that asked the question decides that he will stick to his approach, your answer is still valid.

It gets tricky when you provide an answer that isn't an improvement but just a different approach. We all know any given coding problem can have many solutions where many of them can be equally correct. By providing alternatives in the answer you will encourage a somewhat opinion based answer spree: people will post whatever approach they prefer.

For this reason it is important to only present alternatives with care. It is my rule of thumb to only present an alternative approach if it is objectively better than the original approach or if it has benefits in certain aspects (readability, maintenance, performance, etc).

It is key that you identify the differences between the approaches and present this in a clear way; this will make it easy for people to interpret why you might have chosen this.

Whether or not having multiple approaches to a problem scenario is a good thing is up for discussion. I believe it enhances the quality of the question in general and will provide a valuable resource for future visitors. Nevertheless the answers should differ enough from eachother to actually warrant multiple answers and they should be of good quality.

From a quick glance at your answer (and the 3 upvotes it received since I opened it) I would wager that your answer has met these conditions and is therefore valid.

Answers are meant to solve the problem, not the code.

1
  • 1
    Thank you for your very well thought out answer. The guidance on presenting reasoned alternatives is especially helpful.
    – jedwards
    Dec 30, 2013 at 23:09
4

Answering in the form of a suggestion does seem to happen. Personally, I try to avoid it unless the question specifically is asking for approaches.

Is it an answer? Yes.
Is it a good answer? Depends on the OP I suppose, and if it helps them. I don't think it deserved a down vote.

The question you linked is kind of a common problem for people trying to do animation in response to keyboard input - how to handle simultaneous keypresses with regards to the animation?

There needs to be some asynchrony, or a game loop, involved which reads from a set of actions and reacts. More than likely this person is only reacting to press actions and not looping while looking for them. OPs code has "//keyReleased is exactly the same but with a false", so it is probable they are accidentally not properly actioning these key presses and then seeing false in their array.

Either way, this was a tough question to properly diagnose as there was no complete demo, and it was a little vague. No one else answered so at least you gave the OP something to work with. Sometimes it is nice to at least get some response instead of just tumbleweeding along.

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