28

Here is the SO question that inspired me to bring this up to meta and hear your opinions.

The OP gets a rather generic and obvious error message but doesn't understand what is causing it... He/She thinks the code is doing something different but in reality it's not.

There have been multiple answers but we're talking just about 2:

I think that if we combined the two answers (explanation + code) that would just be super awesome, but this is not what happened - intentionally, at least from me.

This is how it works from my perspective:

I clearly don't have or don't want to spend my time rewriting someone else's hundred lines of code in such a localized question. It's too lengthy and there are way too many sections of the code that could be improved. I don't want to just copy-paste those hundreds of lines while fixing one for loop or an if-else statement... When I am posting an answer that includes some code, I want to make sure all sections of it are improved, not just a single line that caused the error surrounded by hundreds of irrelevant lines of code... Always thought that's the whole point of a Minimal, Complete, and Verifiable example? Reusability + thinking of future visitors.

I hope you see the picture because now...

I guess I was a bit irritated when I noticed that someone else got the 100 points from the bounty while I believed that my answer "got it right" but on the other hand all the upvotes make up for it so it's not really that big of a deal...

My other argument is that any future visitor searching for the problem will be in his own script, localized and customized to his own needs, under different circumstances and I believe that visitor would benefit more from the explanation of the cause of the error rather than a localized code answer.

So, do I tell the OP what is causing the error (teaching to fish) or just dump a working code and say someone else can explain to you what caused it?

8
  • 7
    Imo, always do your best to try to explain why the OP is getting error X, or wht the OP's code doesn't work. Like you said, teach a man to fish and all that... The knowledge to solve a issue is better than a solution the OP might not understand, but works.
    – Cerbrus
    Oct 17, 2014 at 8:37
  • 8
    Good answers do both. Oct 17, 2014 at 8:58
  • 4
    @HansPassant I disagree.. great answers do both, good answers teach and not quite that good answers give.
    – Vogel612
    Oct 17, 2014 at 9:05
  • 9
    Hmm, no, a question like that will never have a great answer :) Oct 17, 2014 at 9:16
  • 1
    Well it happens... Like the answer says, Been there, done that... If you look at that post, the accepted answer doesn't even accomplish what the original questions asks for.. I don't think you can do anything about it.. its completely up to the OP...
    – T J
    Oct 18, 2014 at 7:33
  • 5
    If you do both, it won't make much difference. Sure, you might get some more points, but if OP would accept the 'fish' answer anyway, they are likely confused by the extra text in your answer. Quite often I got comments from OPs or other people about a code snippet I posted, while a complete explanation was in my answer already. For some reason, people tend to overlook the rod completely when they see a fish.
    – GolezTrol
    Oct 18, 2014 at 7:35
  • @GolezTrol That's because hunger can make you blear-witted!
    – matpop
    Oct 18, 2014 at 10:07
  • 3
    I'm very glad that the fishing lesson is upvoted much more than the free fish. It shows that the SO community in general believes more in learning and teaching than in simply handing out quick solutions to problems. Unfortunately we do have a lot of users who simply hand out the fish disregarding the general community belief.
    – ADTC
    Oct 18, 2014 at 20:04

2 Answers 2

44

So, do I tell the OP what is causing the error (teaching to fish) or just dump a working code and say someone else can explain to you what caused it?

Been there, done that. On one question with a bounty, I posted an answer that taught the OP how to fish, but someone came along and posted an answer that gave him the fish (with credit to my answer) and this answer got the bounty.

I'm going to continue doing what I think furthers the greater good: give priority to teaching how to fish instead of merely handing out fish. Typically, I try to do both in a single answer but sometimes that's not possible and sometimes I don't give the fish because I misjudge the situation.

8
  • BTW, it was Community ♦ that awarded the bounty, not OP yet his answer doesn't seem to fit the criteria to be autoseleted (score >2). I wonder how that happened....?
    – Braiam
    Oct 18, 2014 at 15:17
  • 3
    As I recall the criterion is score >= 2 to get half the bounty or accepted to get the full bounty (and the bounty was offered by the OP). The answer was accepted. If it was accepted before the deadline but the OP did not manually award the bounty, then the bounty is automatically awarded. In this case then it would show that it was awarded by Community, perhaps? (I checked the Q's timeline. Useless...)
    – Louis
    Oct 18, 2014 at 17:07
  • But if the OP doesn't read it, will it matter? The answer will likely be more useful to the OP than to anybody else.
    – simonzack
    Oct 20, 2014 at 7:07
  • @simonzack I'd expect a correct answer to the question to be more immediately useful to the OP (or the bounty giver) but over time it may be useful to other people.
    – Louis
    Oct 20, 2014 at 8:51
  • I think that guidance questions are really for people without programming experience asking specific questions, so I doubt if most of these answers will help others.
    – simonzack
    Oct 20, 2014 at 9:38
  • There really is no cure to what the OP is going to upvote/accept...even though you get it right and give a better answer + code... that's alright though, I'll stay around to hit the 20K rep and then I will stop answering.
    – user2140173
    Oct 20, 2014 at 11:42
  • @vba4all I've taken a break from SO earlier this summer. It was a good thing.
    – Louis
    Oct 20, 2014 at 12:04
  • @Louis yeah maybe I need that too haha
    – user2140173
    Oct 20, 2014 at 12:07
4

So, do I tell the OP what is causing the error (teaching to fish) or just dump a working code

Ideally you should do both. If you do not have enough time then I suggest concentrating on the explanation part.

Having said that, whether you choose to explain the problem or post a working code example is completely up to you. Likewise, whether someone chooses to upvote or accept an explanation-only or code-only answer (or both) is up to them. You cannot control that.

[For questions where the problem is too obvious]: Yet another approach to handle these questions is not to answer them at all. Just add a "spoiler comment" below the question and move on.

1
  • Actually, I have to take that back - it turns out you're right
    – user2140173
    Oct 20, 2014 at 11:45

You must log in to answer this question.