30

This SO question: Too many 'if' statements?

Currently closed as off-topic:

This question appears to be off-topic because it is about improving the cleanliness of existing working code. Code Review is where this question belongs. This is exactly what Code Review is about. – Simon André Forsberg

I agree the question fits Code Review, but does that make it off-topic on Stack Overflow specifically? There are literally hundreds of votes and thousands of views on the question and its answers so apparently also the SO community has found it useful and appropriate. Just closing it serves neither Stack Overflow nor Code Review communities.

I am thinking of either:

  • Reopen: allow further answers and more visibility.

  • Migrate: move to more appropriate SE site.

Yes, I have personal interest there as I've posted the most upvoted answer. I voted to reopen once when the question was closed as too broad - now seeking more feedback from the community.

4
  • FYI: I have flagged the post for migration to Code Review but it has not been handled yet. So I didn't 'just close it'. Commented Mar 24, 2014 at 11:13
  • 11
    The question starts with the following code does work how I need it to, but it's ugly, excessive or a number of other things, which makes it a textbook candidate for migration to code review indeed. I'll add my own flag, we'll see what comes out of it. Commented Mar 24, 2014 at 11:14
  • 2
    related: meta.stackexchange.com/questions/181569/…
    – Servy
    Commented Mar 24, 2014 at 15:37
  • The question certainly does seem to belong in CR. As suggested it probably would have been best to close the OP and reopen in CR. In the question's favour I feel such a large quantity of very different solutions may not have appeared on CR. So for that I am thankful.
    – TomFirth
    Commented Mar 26, 2014 at 7:49

6 Answers 6

24

There are cases when a question shouldn't be migrated:

  1. It's not actually off topic for Stack Overflow. There are overlaps between the sites and some questions fall into these areas, and working out which side of this fuzzy border a question lies is tricky. For Code Review it's particularly tricky. Just when does some inefficient code (for example) switch from being just ugly and potentially hard to maintain to being a problem that needs fixing now.

    Personally I think this question is in the overlap, but on the Code Review side of that overlap, so ideally it should have been migrated, but for the reasons I outline below it's too late for that now.

  2. Where a question has an accepted answer there is no benefit to the question for it to be migrated. The OP has got the answer they need and they aren't going to come back and revisit it any time soon.

  3. Where the question and/or answers are highly upvoted. This has been mentioned by psubsee2003 and is a real concern. It gives users with potentially no history on a site a higher reputation than they would have earned had the question and answers been posted there in the first place. This happened on Programmers and was a real problem for a while. Also it makes the likelihood of a better answer from the new community being posted, or if it is posted, recognised vanishingly small.

  4. Where the question has lots of answers - basically for the reasons outlined above.

These reasons are, in part, why questions older than 60 days can't be migrated at all.

For Stack Overflow a successful migration has to happen in the first few hours of a questions life. Unfortunately because of the size of the close review queue on Stack Overflow this is unlikely to happen. I don't know what the answer is, but migrating a question like this isn't going to help the question or either site.

27
  • Regarding #1: If you consider that then all questions on Code Review is on topic for SO, does this mean that you shouldn't migrate any questions? Commented Mar 24, 2014 at 12:02
  • 6
    IMO the question should have been referred to CR when it was being posted, before the 5k+ views on it happened. I assume the reason for why it wasn't was that it was a clear and useful question - much better a question than what SO normally sees. Commented Mar 24, 2014 at 12:04
  • @SimonAndréForsberg I don't think that all questions on Code Review are on topic for SO. There are clear cases where you have adequately working code (there are no speed, memory issues etc.) but there could be just a better way of doing what you are doing.
    – ChrisF Mod
    Commented Mar 24, 2014 at 12:04
  • 1
    @SimonAndréForsberg I agree that the question should have been migrated sooner. However, given the size of the review queue and moderator flag queue I don't see how that could have happened.
    – ChrisF Mod
    Commented Mar 24, 2014 at 12:05
  • "There are clear cases where you have adequately working code (there are no speed, memory issues etc.) but there could be just a better way of doing what you are doing." Isn't that exactly what this question is all about? Commented Mar 24, 2014 at 12:10
  • @SimonAndréForsberg Possibly. However, see my other points which I believe override this.
    – ChrisF Mod
    Commented Mar 24, 2014 at 12:38
  • I understand your points, and they make sense. Ideally (in my world at least) the question should have been copied to CR and closed on SO. That way, SO folks could keep their reputation and CR would get it's own votes on the question. (I know, I know, cross-posting is frowned upon, that's why I'm thinking reposted) Of course there's not much use in reposting it now though. I just find it a bit funny that it should have been migrated but it wasn't. Commented Mar 24, 2014 at 12:54
  • 2
    @SimonAndréForsberg I just find it a bit funny that it should have been migrated but it wasn't. Currently, there are 2k+ items in the flag queue to be reviewed. That means a good candidate to be migrated can get lost in the queue before it gets acted upon.
    – Taryn Mod
    Commented Mar 24, 2014 at 13:03
  • 9
    @SimonAndréForsberg It might be a good idea to involve the CR mods (assuming they are they active in CR's chat room) next time you find a good CR question on SO. CR mods have a direct line to SO mods, and can speed up such migrations considerably.
    – yannis
    Commented Mar 24, 2014 at 14:03
  • 1
    @Yannis Sure thing, will do. And I am hoping the SO community will also communicate with the SO mods, which will be able to communicate with the CR mods, for any questions like this in the future. I assume the SO mods are well-educated by now on which questions that belong on CR and which questions don't. Commented Mar 24, 2014 at 14:16
  • 5
    That's probably the sanest solution @retailcoder, however CR needs to graduate first. And I'm not sure that will happen anytime soon (although I sincerely hope it does, the site is awesome).
    – yannis
    Commented Mar 24, 2014 at 15:36
  • 2
    @retailcoder That likely will happen if/when SE is confident that the CR community is capable of dealing with all of the questions that SO will send to them. Up until now it has been stated that they didn't fell there were enough active users with sufficient reputation to handle all of the questions (and the inevitable stream of crappy questions) sent over from SO.
    – Servy
    Commented Mar 24, 2014 at 15:43
  • 1
    @Servy Regarding "the inevitable stream of crappy questions", I think what's needed there is to educate the SO users about when to suggest CR and when not to. Every now and then we close a question on CR where the OP has been directed to CR from SO, and we educate SO users on when to not send a question to CR (most commonly the code that doesn't do what it supposed to do, which instantly makes it off-topic for CR). Commented Mar 24, 2014 at 15:58
  • 4
    "I think what's needed there is to educate the SO users about when to suggest CR and when not to" Good luck with that @SimonAndréForsberg. We've been trying to do the same for Programmers and failing (hard), for a couple of years. /sigh
    – yannis
    Commented Mar 24, 2014 at 16:01
  • 1
    I just read the link that was posted by Servy as a comment to the main question, and not migrating something that has good answers hasn't stopped migration before, this being the only thing I see holding this question here and "on-topic". should we not migrate questions from CR to SO if someone has answered it and it get's upvotes? would that not pollute our question base and make our on-topicness ambiguous? will it not do the same thing on SO?
    – Malachi
    Commented Mar 24, 2014 at 16:08
12

I have seen SO folks commonly referring questions to CR, and often closing them because of one reason or the other (often I think it's that they 'can't bother helping them when there's no obvious programming error).

Either way, I think that in the long run it would be helpful to both CR and SO to migrate the question, because:

  • CR needs good and popular questions to increase awareness about the site, and to hopefully soon graduate. (We believe that we're not that far away).
  • SO doesn't need more "review my code" / "can I write this better" questions.

Regarding your reputation concerns, it tends to be much easier to get a lot of reputation on Code Review than on SO (at least for regular, non-hot-question questions), because there is sooo much "trash" on SO and not as many questions on Code Review.

4
  • 4
    The number of votes will certainly be a problem though. If migrated, it will instantly be the highest voted question by 2x and the highest voted answer will be the highest voted by 1.5x. Commented Mar 24, 2014 at 11:33
  • 1
    @psubsee2003 I don't see the problem about that? But I added to my answer that it's at least easier to get reputation for non-hot-question questions. Of course there are plenty more users on SO so there are more people who can vote. Where does that leave us? That doesn't make it a reason for the question to stay on SO IMO. Commented Mar 24, 2014 at 11:39
  • 1
    I think ChrisF covered the why behind the problems with migrating highly voted posts pretty well, but ultimately the voting has always been a fundamental problem with migration. Reset votes on migrated questions was a proposal to try to address that problem, but it was declined. Maybe it needs a new look or another feature to handle this. Commented Mar 24, 2014 at 12:32
  • 3
    @psubsee2003 Ok, with ChrisF's answer I understand your point. I don't want the SO answerers to lose their reputation at all. Perhaps the best thing would have been if the SO community would have reacted earlier and directed the user to CR, and then once the question was reposted, the original could have been closed (with any potential existing answers kept and voted on). Commented Mar 24, 2014 at 13:26
11

As a general rule, we do not migrate questions to beta sites.

We'll make exceptions in cases where the question is blatantly off-topic where it was asked and clearly a good question where it is being sent - but these are evaluated on a case-by-case basis, and the default response for open, answered questions is "NO".

Regardless of how well you think this question might fit on CR, it was asked and answered on Stack Overflow. If the only rationale given for closing it amounts to, "this could have been asked and answered elsewhere" then it can stay where it sits - migration doesn't magically turn "what might have been" into "what was".

There are probably plenty of other questions languishing in Unanswered that would benefit from being relocated to Code Review. I would discourage you from looking for them, but if you happen upon a really good one while browsing the site, don't hesitate to suggest that for migration.

See also: Respect the community – your own, and others’

Finally, be extremely reluctant to migrate old, answered questions. The votes and answers on these reflect the opinions and work of the community where they originated, and in most cases they’ll be somewhat out of place elsewhere – you want your greatest hits to reflect the best that your community has to offer, not someone else’s. And, again, the migration can come across as rude: if someone has invested serious effort into an answer and has linked to it on their blog or from their résumé, then snatching it from them without due consideration won’t endear them to you. Only migrate these questions when the alternative is deletion.

1
  • Trust me, I don't plan on looking for old questions that could be migration candidates. Commented Mar 25, 2014 at 11:56
6

Vote for Migration to Code Review

any working code isn't really on topic for SO, no matter how many if statements it has in it. if they are trying to see how many if statements they can get into the code, then it would be a good question for Code Golf and not StackOverflow. so why wouldn't code where someone wants a review of their code not migrated to Code Review?

if you all want to see Code Review succeed then send it the questions that are supposed to be sent to Code Review.

this question is exactly what we do, everyday.


UPDATE

Code Review Has Graduated!


UPDATE

All the people that like this question, and the answers, and voted for all of them should find themselves on Code Review.

We would Graduate in no time, if this question got that much attention here, then those people would love Code Review!

Check out this Question if you don't believe me. It seems very similar (and yes I am Rep Whoring my own question for the sake of this answer)

https://codereview.stackexchange.com/questions/39828/can-you-replace-a-replace-statement-or-9

Here is an Answer that is similar as well

https://codereview.stackexchange.com/a/43945/18427

23
  • AFAIK Code Review isn't a migration target from SO (beta sites are never migration targets).
    – yannis
    Commented Mar 24, 2014 at 15:35
  • doesn't need to be for a moderator to migrate it there
    – Malachi
    Commented Mar 24, 2014 at 15:35
  • 2
    @Yannis then flag for diamond attention and give: "requesting migration to CodeReview" as reason...
    – Vogel612
    Commented Mar 24, 2014 at 15:35
  • That happened here @Vogel612, check the first comment under the question. However, the SO mods didn't get to the flag in time (which is quite understandable, given their workload). When a SO mod did check the question, it was already too late (check ChrisF's answer for details).
    – yannis
    Commented Mar 24, 2014 at 15:37
  • 3
    Yes it does @Malachi. Regular users can only flag and ask the SO moderators to move the question for us (and that happened), we can't directly vote to migrate to sites that aren't migration targets.
    – yannis
    Commented Mar 24, 2014 at 15:39
  • so maybe we need to extend the time that migration can happen in, @Yannis ?
    – Malachi
    Commented Mar 24, 2014 at 15:41
  • That question now has over 100 votes and the answer over 300 votes. Migrating posts with such a high score to a beta site would be toxic. If votes were reset on migration I'd be in favor of migrating. Commented Mar 24, 2014 at 15:42
  • @Malachi It's not about time. CR needs to graduate first. When it does, we can setup a direct SO -> CR migration path.
    – yannis
    Commented Mar 24, 2014 at 15:42
  • 2
    @Gilles, all the people that like this question and the answer string should find themselves on Code Review. we would Graduate in no time, if this question got that much attention here, then those people would love Code Review!
    – Malachi
    Commented Mar 24, 2014 at 15:44
  • 3
    Be careful what you wish for @Malachi. That much attention is not always manageable on the smaller sites...
    – yannis
    Commented Mar 24, 2014 at 15:46
  • 4
    @Malachi No, definitely not. This is a very easy question compared to most CR.SE questions. If this question was migrated, it would become a poster for CR.SE, but it's atypical, and all the attention you'd get would be people looking for similar easy pickings and leaving the interesting ones untouched. Furthermore, having such atypical questions as your poster child would discourage the people who you really want, who are interested in the run-of-the-mill CR questions. Commented Mar 24, 2014 at 15:51
  • 1
    @Malachi And everyone else's point is that certain questions aren't suitable for migration even if they are offtopic on their current site and on topic on another, and this is one of those questions. All of the votes that it has, along with the number of answers, makes it unsuitable for migration. Had it been suggested right away, it could have been a candidate for migration.
    – Servy
    Commented Mar 24, 2014 at 15:58
  • 1
    @Malachi It has caused significant problems when migrated though, which is why the policy is now in place that questions with lots of answers, or highly voted answers, should avoid being migrated, unless there's a particularly compelling reason to (which I don't see here). Chris has gone over this in his answer.
    – Servy
    Commented Mar 24, 2014 at 16:13
  • 1
    @Malachi The question can be closed on SO, yes. I'd personally go with "too broad" here; that's generally appropriate for most, "here's some code, how can I make it better" questions.
    – Servy
    Commented Mar 24, 2014 at 16:18
  • 2
    StackOverflow-like issues? the code works. the code compiles. the code functions the way that it should. I thought that StackOverflow was for code that doesn't function properly and the Poster can't figure out why - type of issues?
    – Malachi
    Commented Mar 31, 2014 at 2:58
-1

I see “Code Review” about making code “better” that is already “ok”, the number of “ifs” in the given code is such that any good programmer would not be happy with it.

Hence I consider it is on topic for Stackoverflow.

10
  • 9
    Code Review is about making any code better that is already doing what it is supposed to do. Putting any line on when code is "ok enough" to be on topic on CR would just create more confusion. Our requirement on CR is that it should be working. Commented Mar 24, 2014 at 14:08
  • @SimonAndréForsberg, I don't think that code is "doing what it is supposed to do" as code is meant to be easy to read and understand why it does what it does. Commented Mar 24, 2014 at 14:11
  • 3
    Readability issues are also on-topic on CR, and in fact one of the things we deal with the most. You should take a look at out on-topic page: codereview.stackexchange.com/help/on-topic Commented Mar 24, 2014 at 14:12
  • @SimonAndréForsberg, that does not make them off topic for SO. Commented Mar 24, 2014 at 15:15
  • 2
    I'm just saying that your understanding of CR as a place for making code that is already "OK" better is incorrect. And no matter if it is on topic on SO or not, on CR it is more on-topic. Commented Mar 24, 2014 at 15:26
  • @SimonAndréForsberg It absolutely is relevant whether or not it is on topic on SO. When a question is on topic on two sites it should not be moved; it should stay wherever it is. Questions should only be moved if they are explicitly not appropriate on the site in which they are posted.
    – Servy
    Commented Mar 24, 2014 at 15:41
  • @Servy I believe I have not said that it was irrelevant whether or not it is on topic on SO. I understand your point but I'd like to add that if SO would never migrate or recommend the OP to Code Review then the purpose of CR gets lost and our graduation would be delayed even further. For a question like this that has gathered a whole bunch of votes already, it's OK to let it stay. But as others have said, preferably it should have moved to CR more quickly. Commented Mar 24, 2014 at 15:53
  • 1
    @SimonAndréForsberg You did say that though, "And no matter if it is on topic on SO or not". I'm not saying that this is on topic on SO. In fact, I'm willing to say that it's not. The fact that this question really doesn't belong on SO is relevant.
    – Servy
    Commented Mar 24, 2014 at 15:54
  • @Servy Ah, perhaps I should have formulated myself differently. "If it is on topic on SO, then it is even more on topic on CR". Commented Mar 24, 2014 at 16:00
  • 1
    @SimonAndréForsberg And I'm saying that if it's on topic on SO, then it shouldn't be migrated, no matter how on topic it is on CR. That's the way migration is handled on SE.
    – Servy
    Commented Mar 24, 2014 at 16:03
-1

This is tricky because it's two questions rolled into one. Remove all the explanation and the code from the question, and what's left is this.

Is there a type of math formula that would benefit me in this instance or are 16 if statements acceptable?

Whether there's a math formula - well, someone could make a case for that belonging on Math.SE, but they'd be wrong. OP really means "is there a closed form using the standard Java operators" - and I feel that Stack Overflow is the best fit for that.

Whether 16 if statements are acceptable - that belongs on Programmers.SE. Not Code Review

So the only valid choices really are Stack Overflow or Programmers. To move it to Code Review would be to miss the point of the question. And honestly, I think we've had better answers from having it on Stack Overflow than we would ever have gotten from Programmers.

You must log in to answer this question.

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