11

As I know, questions about non-working code can fit on Stack Overflow, while already working code should be on Code Review. But what about code where I'm not sure it is working?

I just found a question that was about checking the correctness of a code. I guess it is asking if there is some missing cases to handle for the input.

Is this type of question on-topic?

6
  • 9
    If one is not sure that it works, maybe writing some tests would make more sense. IMO it's better than scrambling together a question and throwing it on SO.
    – byxor
    Commented Oct 17, 2016 at 2:35
  • 3
    Just FYI, the question you linked to has been deleted. So I'm guessing that it was not considered on-topic. Commented Oct 17, 2016 at 16:48
  • 1
    As an aside, "correctness of codes", "correctness of a code", there is something grammatically wrong about that. Commented Oct 17, 2016 at 19:51
  • 2
    If the code works as far as you know and you just have a healthy curiosity about any unanticipated edge cases in which it might not work, that doesn't disqualify it from Code Review. If you have no idea whether it works and you want someone to spell it out for you, that definitely disqualifies it. In my experience, questions about potentially working code will clearly fall in one or the other category; there's not that much gray area in between.
    – Thriggle
    Commented Oct 17, 2016 at 19:57
  • ...how do you not know if your code works? Try running it. Commented Oct 19, 2016 at 8:09
  • "I'm not sure" is anything but a clear problem statement. Commented Sep 20, 2019 at 18:53

2 Answers 2

36

The problem with this is that it doesn't really have a good answer to it. Whether or not the code works, given some constraints, is either yes or no.

This is where things start to get uncomfortable.

At this point, after the definitive answer on whether or not the code works, the OP would like some sort of dialog on what could be improved. Now, this could be something as simple as mixing up a value somewhere; it could be as broad as, "This entire code is broken beyond repair and only a rewrite will save it."

This in my mind makes these questions too broad. There's too many ways that this code could or could not work.

The only real salvation to this type of question would be if the OP could narrow down the problem space; instead of asking if this code is OK in general, they could ask why the code wouldn't work in these specific cases, and provide those cases in addition to their code. The key critical thing here: we can't allow for a dialog on the state of their code. We need them to narrow their question and be prepared for an answer with respect to that scope.

10
  • Would it be suitable on Programmers.SE?
    – Ali Bdeir
    Commented Oct 17, 2016 at 16:21
  • 8
    @AbAppletic: No.
    – Makoto
    Commented Oct 17, 2016 at 16:21
  • 8
    But maybe on codereview.stackexchange.com. They say "The quality of your working code with regards to: Correctness in unanticipated cases" Commented Oct 17, 2016 at 18:13
  • 4
    @ThomasWeller: Probably not, since it doesn't appear to satisfy one of the particular criterion of reviewed code, in that it is actual, real code.
    – Makoto
    Commented Oct 17, 2016 at 19:01
  • @Makoto: oh, they review quite much over there. You can tag as [beginner]. Commented Oct 17, 2016 at 19:04
  • 2
    @ThomasWeller: Maybe. I'm always gun-shy about sending questions over there since I don't fully understand what's on-topic at all times, and most of the questions that are pitched to go over there are terrible.
    – Makoto
    Commented Oct 17, 2016 at 19:06
  • 7
    @ThomasWeller I recommend you to not blindly recommend sites to post questions unless you are not alien to their specific scopes and quality expectations. Code Review is for code that you know that works, it does what you meant it to do, and want a third opinion about how to make it more resilient, reusable and clearer (aka code not written while you were drunk).
    – Braiam
    Commented Oct 17, 2016 at 19:29
  • 2
    @Braiam: I don't see how I blindly recommended something. I even cited parts of the using instructions: "of your working code". Also, I wanted to give a suggestion to AbApplectic, not necessarily to the OP and I definitely don't want the deleted question to go there. But I think too few people are aware that CodeReview exists. On any site, posters should check the guidelines. Commented Oct 17, 2016 at 19:43
  • 7
    @ThomasWeller just make sure that when you raise awareness of codereview on SO, raise awareness to this too. Commented Oct 17, 2016 at 20:08
  • 2
    @AndrasDeak: thanks. I wasn't aware of it. Starring it for reuse Commented Oct 17, 2016 at 20:11
-2

You should totally drop that and try Code Review.

It's a Stack Exchange specifically for this purpose.

2
  • 1
    Careful; you're walking into a landmine there. Don't just go up and recommend Code Review without being certain the question will fit on there.
    – Makoto
    Commented Oct 19, 2016 at 4:20
  • @Makoto oh - I didn't read the comments in your answer. Maybe there should have been some content in your answer explicitly saying why Code Review may not be a good fit. Commented Oct 19, 2016 at 4:29

You must log in to answer this question.

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