Re:Avoid Else, Return Early (2013)
by timoxley on Monday March 26, 2018 @10:55AM
(#16679332)
> ... makes case analysis easier ...
> ...making the code look less complicated than it actually is...
> I'd rather emphasize the underlying declarative intent, the state machines, and pre/post-conditions.
These statements are strange to me as I personally see early returns as attempts as achieving exactly these goals. I guess people unroll logic in their head in different ways. "flat" to one may appear "nested" to another and vice versa.
> ...making the code look less complicated than it actually is...
> I'd rather emphasize the underlying declarative intent, the state machines, and pre/post-conditions.
These statements are strange to me as I personally see early returns as attempts as achieving exactly these goals. I guess people unroll logic in their head in different ways. "flat" to one may appear "nested" to another and vice versa.