Consider the two following coding-styles:
Nested conditions:
if(is_numeric($user_id)) {
// .. do stuff
if(is_valid_user($user_id)) {
return foo($user_id);
} else {
return FALSE;
}
} else {
return FALSE;
}
vs. just simply stopping when something is wrong:
if(!is_numeric($user_id)) {
return FALSE;
}
// .. do stuff
if(!is_valid_user($user_id)) {
return FALSE;
}
return foo($user_id);
This is of course at least partially about taste; but what are these two different styles called?
When are one prefered over the other?
Are there other, perhaps cleaner, coding styles?