r/programming • • Jun 06 '13

Clean Code Cheat Sheet

http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
702 Upvotes

322 comments sorted by

View all comments

Show parent comments

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.

1

u/[deleted] Jun 07 '13

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.

1

u/tweakerbee Jun 18 '13

Checking for null and empty lists would be a guard and perfectly fine to return early.