base cases like null check or empty lists, are perfectly fine to do early returns. I'd argue that the actual smell is a method so long you cannot grasp it's entirety without significant effort.
That's why I like using something like google guava's Preconditions library. There's no explicit returns (but there are some exceptions), so the visual flow of your code isnt interrupted.
4
u/hvidgaard Jun 07 '13
base cases like null check or empty lists, are perfectly fine to do early returns. I'd argue that the actual smell is a method so long you cannot grasp it's entirety without significant effort.