DEV Community

Cover image for When you are writing code, do you "align the happy path to the left"?

When you are writing code, do you "align the happy path to the left"?

Damien Sedgwick on March 20, 2024

The two code snippets in this post (which are images to help highlight the indent columns) are identical in terms of desired outcome, but they coul...
Collapse
 
davesmith profile image
Dave Smith

Yep. I’m surprised how often I see the first example. I think some people were taught that your function should only have one return. I remember one professor teaching that style, but it was C code and some 20 years ago. It’s good to keep readability as a top priority and this style helps so much

Collapse
 
damiensedgwick profile image
Damien Sedgwick

I could not agree more on making readability a top priority! Thanks for commenting.