Consider the following two code examples:
1.
void foo(boolean cake) {
if (!cake)
return;
// TODO some work.
}
2.
void bar(boolean cake) {
if (cake)
//TODO some work.
}
Which one is the most readable/ semantic correct? With the first example you avoid additional indentation on the below code.
Should one return right away when there is no cake or not?