medium.com/@matryer/line-of-sight-in-code-186dd7cdea88
1 Users
0 Comments
7 Highlights
0 Notes
Tags
Top Highlights
the happy path flows down the left hand edge,
Tips for a good line of sight:
Align the happy path to the left; you should quickly be able to scan down one column to see the expected execution flow
Don’t hide happy path logic inside a nest of indented braces Exit early from your function Avoid else returns; consider flipping the if statement Put the happy return statement as the very last line Extract functions and methods to keep bodies small and readable If you need big indented bodies, consider giving them their own function
we indent only to deal with errors and edge cases,
our happy return statement “return nil” is in the last line, and
we have fewer indented code blocks.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.