Quite often I have an if
statement where I have two cases, one of which requires a one-liner and one of which needs lots of code to be dealt with. From a readability point of view, which should I put first, given that I don't know how likely each one is? So:
if(flag) {
// lots and lots and lots of code
// blah
// blah
// blah
// blah
// blah
// blah
// etc
} else {
// easy one liner
}
compared to
if(!flag) {
// easy one liner
} else {
// lots and lots and lots of code
// blah
// blah
// blah
// blah
// blah
// blah
// etc
}
Note: This is not a performance question, but a readability/ease of maintenance one.