Programming style: should you return early if a guard condition is not satisfied?
I prefer the first style, except that I wouldn’t create a variable when there is no need for it. I’d do this: // Style 3 public SomeType aMethod() { if (!guardCondition()) { return null; } SomeType result = new SomeType(); doStuffToResult(result); doMoreStuffToResult(result); return result; }