6

So I bumped into this dilemma today. A user asked a question about a NullPointerException. Another user gave an answer which contained very good advice for the code, but didn't really explained the reason for the NullPointerException nor solved it.

My questions is: should I upvote his answer or not? It was very good advice, but didn't really provided a solution.

Here's the question: Drawing images with time delay

7
  • 2
    Very often the problem the user is asking about is the very least of the issues. If the answer results in the avoiding the posted problem, then I'd say it is a good answer. It was very good advice and yet you advocated the exact opposite in your answer as regards getGraphipcs(). Commented May 5, 2015 at 15:14
  • 1
    It's a fairly different question, but the answer applies almost exactly to this question: meta.stackoverflow.com/a/276305/1159478
    – Servy
    Commented May 5, 2015 at 15:18
  • 1
    Its depends on you whether you up-vote or not.But normally If I see a link only answer I try to read another answer.So I think link only answer does not help me that much. At review task I recommend delete even that link provide good answer. Commented May 5, 2015 at 15:24
  • @Plutonix, to be honest, I saw his reply when I posted my answer (which I will delete depending on the outcome of this thread).
    – Tavo
    Commented May 5, 2015 at 15:24
  • 1
    There isnt actually a question in the OP's post, but it seems to be how to paint with a delay which the java gold tag user seems to have answered. Your deals with why they got the nullpointerexception. If the other answer both avoids the exception and paints with delay, I'd say it is more complete. Commented May 5, 2015 at 15:32
  • You are right. I just assumed that he wanted to get rid of the NPE, hence my doubts about the answer.
    – Tavo
    Commented May 5, 2015 at 15:34
  • 1

1 Answer 1

7

Personally, I'd say that the linked answer offers an alternate solution that will involve enough code rewriting that the Exception will be moot (and fixed by preventing its occurrence). It's like this situation:

Q: How can I rewire my device to turn on when my batteries are backwards?

A: You should really put the batteries in their correct orientation, which for your device is like so: (explanation)

If you feel this alternate approach/solution is useful enough to warrant a rewrite of code (and it explains how to rewrite the code well enough), then it's useful and upvotes are appropriate. Otherwise, if you feel the advice is irrelevant or subpar, you can downvote it for not actually being helpful in answering the question.

6
  • As much as I agree with your comment, my dilemma comes from the fact that yes, the user will use a new approach that will get rid of the exception. But when faced with a NullPointerException again, he will have to ask (almost) the same question.
    – Tavo
    Commented May 5, 2015 at 15:31
  • 2
    @Tavo following the best practices, the user will encounter the Exception, in a completely new context. This (assuming it's not closed) will warrant a completely separate answer from the original question.
    – ryanyuyu
    Commented May 5, 2015 at 15:36
  • But then the user will have more knowledge of why it happens and might be able to resolve it on his own.
    – Tavo
    Commented May 5, 2015 at 15:37
  • 2
    @Tavo so you're saying that the original question is more like what is an exception and how do I fix it? That is a really broad question that entire books are devoted to. Keep in mind that your response to fix this immediate (NPE) problem is still useful. But the alternate approach has the potential to be also useful.
    – ryanyuyu
    Commented May 5, 2015 at 15:40
  • Sorry, I might not have been clear in my comment. I was talking specifically about the NPE in his case, not NPEs in general, not exceptions in general either.
    – Tavo
    Commented May 5, 2015 at 15:48
  • 2
    @Tavo Like I said, both answer have two separate approaches to solving a problem. Both can be independently useful (or not). Fixing this specific NPE is useful, and so is rewriting code to completely avoid a bad situation that lead to this NPE. If the user still runs into a NPE in a different context, a new question is fine. If it's the same context, the user has your answer as guidance.
    – ryanyuyu
    Commented May 5, 2015 at 15:51

You must log in to answer this question.

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