a
a
aizatto.com
Build.my
GitHub
Linkedin
Notion
Search…
aizatto.com
Table of Contents
Portfolio, Projects, Tools, Toys
Interview Guide
Engineering Code
Communication
Different Types of Coding
Commit Messages
Reviewing Code
Writing Code
Consistency
Writing for a code base of 1,000,000+ Lines
Write Code Knowing It Will Be Refactored
Naming
Commenting
Make It Easy To Reproduce
Scripts
80 character limit
Exit Early
Be careful of enum in switch statements
Be careful about chaining conditions
Be careful of chaining ternary operators
Write Code Knowing You Will be Blamed
Hacks
Bad Practices
Logs
Time
Other rules
Engineering Code
Engineering Data
Pipelines
Configuration Files
Site Reliability Engineering (SRE)
Best Engineers
Engineering Management
Why GitBook?
Getting into Tech
Personal Goals
Daily Drivers
Contacting Me
Notes
AWS
JavaScript
Node.js
Software Engineering
Technical Due Diligence
Web Development
Archive
More on Notion
Powered By
GitBook
Exit Early
Discourage:
1
if
()
{
2
...
3
return
false
;
4
}
else
{
5
...
6
return
true
;
7
}
Copied!
Encourage:
1
if
()
{
2
...
3
return
false
;
4
}
5
​
6
...
7
​
8
return
true
;
Copied!
Reasons to exit early:
Process of elimination
Reduces cognitive load
Reduces indents
We know success will always be at the end
Structures your functions:
Validation/error handling at the beginning
Successful at the end
Resources
​
https://news.ycombinator.com/item?id=16678209
​
​
https://www.itamarweiss.com/personal/2018/02/28/return-early-pattern.html
​
​
https://softwareengineering.stackexchange.com/questions/18454/should-i-return-from-a-function-early-or-use-an-if-statement
​
​
https://blog.timoxley.com/post/47041269194/avoid-else-return-early
​
Arguments against:
single exit point
​
https://www.tomdalling.com/blog/coding-tips/coding-tip-have-a-single-exit-point/
​
Previous
80 character limit
Next
Be careful of enum in switch statements
Last modified
2yr ago
Copy link