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?
Return explicitly or implicitly?
java
Usually you get the advice to avoid multiple exit points in a method. However the reasoning behind this rule is only valid if you have long methods - and then you have more to worry about than exit points.Make your methods short, then make them even shorter. After this you can use whatever exit style you want, because it will be readable either way.I came to this conclusion myself, but good books like Clean Code by Robert C. Martin will tell you the same.