If I'm faced with a typical coding problem to which I don't know the solution it seems natural/logical to post the question on Stack Overflow and ask others for a solution.

However, if I already have a working solution but am wondering whether a better solution exists, should I still post that on Stack Overflow or is it perhaps better suited for Code Review (or even somewhere else)? From one perspective, I do already have working code and am asking others to review it in order to perhaps suggest a better alternative, i.e. I should post it on Code Review. However, I don't want to waste the time of people on Code Review if this type of question really should stay on Stack Overflow, as it really is just asking for a coding solution to a particular problem.

I could just not include my working solution in my question and post it to Stack Overflow as a standard naive question. However, that seems a bit disingenuous and is potentially asking others to waste their time coming up with a solution I already have. Moreover, if I already know one (potentially obvious) solution to the question, I don't want to waste my time by responding to others coming up with the same solution. And in fact, my real question is, given the fact that I already know a particular solution, is there an even better way of doing it?

So, where should I post such a question?

  • 6
    In general. working code goes on CR but you need to describe a clear goal you expect from the review.
    – rene
    Feb 2, 2017 at 20:43
  • @rene, thanks for the input. I recently posted this question on CodeReview. In it, I state that I want to do X. I have a working solution, but it requires deliberately throwing an error. So I'm asking if anyone can suggest an alternative solution that will still accomplish X but without needing to throw an error. To my understanding, that fulfills the criteria that you describe, i.e. that my question clearly states the goal I expect from my code review. Feb 2, 2017 at 20:50
  • That is not working code, by my definition. That is at best an POC. But I doubt it would fly on SO either ;(
    – rene
    Feb 2, 2017 at 20:54
  • But it is working code (JavaScript) if I put my error-throwing-code within a try...catch block and then put my desired functionality within the catch block. i.e. try { ...potentially-error-producing-code... } catch { ...do-something-useful-if-an-unavoidable-error-was-thrown... }. If it helps, please see the question I link to in my above comment to see why I had to do it that way. However, that's just the specific issue I was dealing with when trying to figure out which community to post to. I do think you've already at least partially answered my meta-question, so thanks for that. Feb 2, 2017 at 21:00
  • 1
    You could include your working code and detail the pitfalls of the solution, asking for a solution that doesn't have those pitfalls. Feb 2, 2017 at 21:01
  • For you it is working but if I copy your code in my IDE and kick it off, it fails.
    – rene
    Feb 2, 2017 at 21:01
  • @GiantDwarf, I think that your approach is a valid one, and it is helpful to hear more about how to ask SO questions, so thank you. That is, in fact, exactly what I tried to do on my question on Code Review that inspired this question here on Meta. Your response, though, gets at my Code Review question, not my Meta question. The question here (on Meta) is not concerned with the solution to the problem but where such a problem should be posted. Feb 2, 2017 at 22:13
  • @rene, I appreciate the insight you're providing into whether my initial question on Code Review is a valid one, and/or what a possible answer to that question might be. However, my question here on Meta (as opposed to the one on Code Review) is not how I should solve my initial question, but where I should ask that question. I'm sincerely wondering whether you think the issue of whether my question includes working code or not is relevant to me deciding where I should ask that question (or, I suppose, whether it's worth asking anywhere). Feb 2, 2017 at 22:22
  • The example is helping to form my opinion if my first comment has value. I personally still it does, so I think that answers your question, however I think your CR example question isn't a good fit for CR but others that are regulars on CR told me the question is OK. I leave the final verdict to anyone who like to write up the general advice
    – rene
    Feb 2, 2017 at 22:27
  • Well, if you do what I described in my comment, the question should be fine for either site, but I only participate in Stack Overflow so I can only vouch for it being on-topic there. Feb 2, 2017 at 22:53


You must log in to answer this question.

Browse other questions tagged .