DEV Community

Discussion on: How I improved my code by returning early, returning often!

Collapse
 
firozansari profile image
Firoz Ansari • Edited

Thank you.
This approach is also known as BouncerPattern:

Bouncer Pattern
The bouncer pattern

Collapse
 
jordanfinners profile image
Jordan Finneran

Thats good to know, I will have a read! Thank you!

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I know that pattern as guard clauses, if it's specifically used to rule out error cases at the beginning of the function.

Assertion is another word for it, but that can mean different things to different people.

The name Bouncer Pattern is new to me, but it is a good metaphor to describe what happens (It prevents unwanted input from "getting inside" the main program logic).