What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

As a new contributor, I have read up on how to answer questions (and there is a lot of information related to that), and am slowly finding my feet, but haven't been able to find any information specifically relating to this.

Some of my answers are very long and took considerable time to write and provide references for (e.g. storing a js value from 1 ActionResult to use in another ActionResult) - these sometimes end up arriving after another answer has been accepted. Some, or rather one, (How to use a UriBuilder and HttpUtility.ParseQueryString to store a URL and parse it) are the opposite - short and concise (I recently read a "meta" discussion on which are better, long answers or short "fire and hope you get the points first" answers, and one of the seemingly popular suggestions was to write a quick, accurate, reply, and then embellish it over time).

The latter of those two answers was downvoted almost instantly, unfortunately with no comment so I can't improve the answer. I have read about and understand the anonymous vote process, so this is not a question about that. I don't take these things personally but would like to learn from it to provide better answers in the future. I did originally provide very little context in the code sample, and then expanded on that in an edit when I re-read my answer.

(brief background: in this case the OP was going from string to object, to dictionary, to string. The regex approach I suggested simply goes from a string to a string - a viable alternative. I understood that the OP was not asking about NameValueCollections, but how to approach the problem).

So, my questions are:

  1. Is it frowned upon to provide alternatives to the direction the OP is going in if you think they are either better, or both valid and thought provoking?
  2. Should I have expanded at length to explain why the alternative is attractive?
  3. Should I, in future, rigidly stick to answering the OP's question (though in this case I felt I was as one of his questions was "Am I on the right track with my code?")

I am hoping I can learn from this one and find the right balance between massive missives for answers which take a long time to write and even longer to read, and terse five-liners that require more effort from the reader to understand why that answer was given.

(And yes, the irony is that I'm also currently wondering if this is an acceptable question to ask, and if this is the right place to ask it).

Edit: the link to the Fastest Gun in the West Problem I mentioned above.

Edit 2: I realise that as I'm probably going to edit my answer as a result of feedback, I should probably record my original answer or this question will become meaningless:

Could you use a regex to parse it instead?

string uri = "website.com/stuff/?referrerPage=1&productID=1234567&tab=Tile";
var rgx = new Regex("productID=(?<pid>[0-9]+)", RegexOptions.IgnoreCase);
string pid = rgx.Match(uri).Groups[1].Value;
share|improve this question
1  
I give the OP alternatives all the time. Solve the problem at hand; if that means ignoring the direct question and looking at the underlying problem, then briefly address the question but point the OP to the better solution. –  Martijn Pieters May 10 '13 at 17:56
    
@MartijnPieters, thank you. Do you think I should have provided more reasons for the alternative in my answer in this case? (I'm using this as a specific case just to try and learn by example rather than by theory). –  Andy Brown May 10 '13 at 17:57
    
Perhaps, yes. Explain why you think a regular expression would solve the problem better. –  Martijn Pieters May 10 '13 at 17:58
2  
Parsing a URL using a regex sounds like a fairly bad idea in any case, and certainly doesn't answer OP's question about using a specific perfectly good URL parsing library. –  Wooble May 10 '13 at 18:01
    
@Wooble. I suppose that could be the reason for the downvote, but is that not an opinion rather than an obviously black and white argument? Are you also saying, in answer to (1) above that it is frowned upon to deviate from answering the main title of the question? In this case the OP also asked "Am I on the right track" with the comment "I'm very new to C#". (Edit: and, thank you for taking the time to help me out.) –  Andy Brown May 10 '13 at 18:05
4  
Up/down votes are made by humans based on their opinion of whether the answer is good or not. Obviously someone thought it was not. –  Wooble May 10 '13 at 18:06
1  
@AndyBrown Remember that the tooltip for voting buttons is not "is this answer technically correct". It is "This answer is [not] useful." If someone provides an answer that technically answers the question, but does so in what many consider to be an inappropriate or in some way irresponsible manor, it can still be unhelpful, or not useful, and thus be downvoted. Likewise an answer that has a minor technical mistake but that still helps the reader get to an answer may be considered worthy of an upvote. –  Servy May 10 '13 at 18:13
    
@Wooble. Thank you, that helps: my take home from your comment is that because votes are opinions, a "valid" alternative can be viewed as "invalid" by someone else, leading to a downvote. It makes sense. –  Andy Brown May 10 '13 at 18:15
1  
@AndyBrown: For example, your regex will extract the wrong parameter if it's given something like site.com/path/?notproductId=42&productId=1337. Using regex when there's a perfectly fine URL parser available just complicates things and adds potential bugs for no good reason. –  hammar May 10 '13 at 18:16
    
@Servy. Thank you for your help, that helps me understand the voting system a little better - it makes perfect sense. –  Andy Brown May 10 '13 at 18:17
    
@hammar: I see where you are coming from, thank you. My view would be that in the context of the information provided ("[The OP wants] to get just the productID [from the following uri format]") it would be an exactly correct answer that could then be built upon for other scenarios. My take home from your help would be that it is good to provide commentary around limitations/adjustments for use as well, I think? –  Andy Brown May 10 '13 at 18:19
    
@AndyBrown I got a downvote once for offering an alternative solution because someone thought that in the specific case specified by the OP, it would add unnecessary overhead. Sometimes going for an alternative solution you risk getting downvotes if they aren't the best solution for the exact scenario painted by the OP. But I still think my answer is valuable because if offers another solution to the problem that no one proposed. –  psubsee2003 May 10 '13 at 18:19
    
@psubsee2003. Thank you, I was thinking that after Wooble pointed out that votes are opinions. Alternatives are potentially more likely to risk downvotes, but I would agree with you: they can be valuable and I have always like that sharing a problem with other people can raise options I haven't considered (whilst trying to find the tree in the wood with a box of safety matches). In my time as a new contributor, though, downvotes have a big % rep impact so I think I'll stop providing alternatives for the moment. –  Andy Brown May 10 '13 at 18:23
2  
@AndyBrown I don't think you need to go that far... the best way to provide alternatives is to answer the question like this: This is how you accomplish x, but this is how I think you could do it better. That way you are still answering the question directly and still providing the valuable alternative. –  psubsee2003 May 10 '13 at 18:26
    
@psubsee2003. Good point - I like that approach. –  Andy Brown May 10 '13 at 18:29

1 Answer 1

up vote 3 down vote accepted

1 - Is it frowned upon to provide alternatives to the direction the OP is going in if you think they are either better, or both valid and thought provoking?

Short answer

No it's not frowned upon.

Long Answer

Keep in mind that your task here is to answer the question. Yes you can provide alternatives. We do it all the time. Especially if you can explain why they are better. Just don't get lost in that path.

Rule of thumb : Did I actually answered OP's question ?

2 - Should I have expanded at length to explain why the alternative is attractive?

Once again it depends.

  • Is it justified ?
  • Will the answer make more sense if I explain it that way ?
  • Is it too much ?
  • Could I refactor parts of it to make it easier to read an absorb ?

If all of this is justified, there is no reason where you should not do it.

3 - Should I, in future, rigidly stick to answering the OP's question

Well I think this one was answered in the first two answers. Just make sure it is justified.

It's a good thing you take the time to learn how it works around here. Too many users just come around and ask for solutions without taking the time to read the guidelines.

share|improve this answer
    
@PhaDoPhunk. Thank you for your answer. I asked (3) explicitly as I suspected that if (1) was "no, not frowned upon" then (3) might still be "yes". You have cleared that doubt up from me. The take home I understand is (to state the obvious) "Did I actually answer the OP's question" –  Andy Brown May 10 '13 at 18:28
    
In case you're still interested, he joined on the 26th of September 2008, today is the 10th of May, so it's actually four years and seven-and-a-half months. That should be enough for the 2086 missing. –  Daniel Fischer May 10 '13 at 19:34
    
@TinSoldiersAndNixonsComin' Oooh that's probably where they went :P ! Thanks –  ʞunɥdɐpɐɥd May 10 '13 at 19:40
    
@TinSoldiersAndNixonsComin'. I'm totally lost - was I meant to understand that? Sorry. –  Andy Brown May 10 '13 at 19:44
    
@AndyBrown No. I deleted my previous post. TinSoldiersAndNixonsComin' still wanted to contact me so posted here. –  ʞunɥdɐpɐɥd May 10 '13 at 19:45
    
Sorry, @Andy, didn't realise that there was only one comment on this post before and thus you'd be notified. –  Daniel Fischer May 10 '13 at 19:47
    
@returnPhaDaPhunk. aaaaah, well that makes sense. That confused me so much it made me go to the pub. –  Andy Brown May 10 '13 at 19:55

You must log in to answer this question.

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