I often write functions with conditional branches like this:
function f
if(X) {
do something minor;
}
else if(Y) {
do something minor;
}
else {
do a whole lot of stuff;
}
I could achieve the same results doing:
function f
if(X) {
do something minor;
return;
}
if(Y) {
do something minor;
return;
}
do a whole lot of stuff
I like that the second one doesn't require I indent the majority of my code, but am not sure if this is considered good practice or not. Since there's no common code following the conditional it seems justifiable to do a hard return. But the first style seems to have merits also.