DEV Community

Discussion on: The Life-Changing Magic of Flat Code

Collapse
 
mmi profile image
Georg Nikodym

This technique is also known by other labels: early returns or return early pattern.

And I'm a big fan.

However, it's worth pointing out that not everyone is on board -- I've even seen it explicitly discouraged in company coding guidelines. Not quite spaces vs tabs battleground but up there :D

Collapse
 
recursivefaults profile image
Ryan Latta

Oh, there are tons of strange things in coding guidelines that companies create. I think that's a whole separate topic :)

My personal favorite from a coding guide: Always use pre-increment in for loops.