https://youtu.be/2a_ytyt9sf8?t=1211
- explanatory variables to group-up code in a condition
- First rule of function is that they should be very small to the point of a few lines only or two indents. Second rule is that every line in a function should be at the same level of abstraction and that level should be one below the name
- Three arguments in a function should be the maximum because anything higher means the arguments are so cohesive that they can be made as an object.
- Mostly never pass a boolean in a function because it means it will have a conditional statement and that can almost be divided into two alternative functions
- avoid switch statements because they do more than one thing and do not follow the open-closed principle.
- Make it polite like a news article to be able to escape some reading. Title -> synopsis -> less details -> mode details
- Create functions with no side effect that don't change the sate of the system. For stateful functions that don't have returns, pass lambdas as arguments to close the state back to normal.
- To keep track of side-effects, follow the convention of keeping things stateless if the function has a return statement.
- Never do nested try/catch blocks and also try to isolate them in their own function that is dedicated to error processing.
- When dealing with complicated loops, insert them in lambdas to separate them from the rest of the code
- The purpose of a comment it to explain the purpose of code if the code can't explain its own purpose. Use comments to compensate for the failure to express yourself in code. Comment as last resort