written By Samuel Štancl
originally on: https://twitter.com/samuelstancl/status/1272822437181378561
https://threadreaderapp.com/thread/1272822437181378561.html
packed By Alessandro Cappellozza
Slides for class discussion
💡IT'S ABOUT THE *MICRO*.
Using some "macro" philosophy for structuring your code, like hexagonal architecture or DDD won't save you.
A clean codebase is the result of constant good decisions at the micro level.
👉Instead of writing repetitive `else if` statements, use an array to look up the wanted value based on the key you have.
The code will be cleaner & more readable and you will see understandable exceptions if something goes wrong. No half-passing edge cases.
👉 Try to avoid unnecessary nesting by returning a value early. Too much nesting & else statements tend to make code harder to read.