Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
pjc50
on March 7, 2023
|
parent
|
context
|
favorite
| on:
Parse, don't validate (2019)
It keeps the code closer to the left. It also keeps it conceptually simpler if you can discard a bunch of "obvious" cases early on.
jakelazaroff
on March 7, 2023
[–]
Yup, this is my exact rationale for preferring this too. Branches are a significant source of complexity and early returns are one way to tame it — have the “meat” of the function deal with as few invariants as possible.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: