5.1. Act Locally.
Keep the scope of mutable variables and open resources short and easily visible.
5.2. Take Small Steps—Always.
Small steps always; check the feedback; and adjust before proceeding.
5.3. Avoid Fortune-Telling.
Only look ahead as far as you can see.
5.4. Decoupled Code Is Easier to Change.
Coupling ties things together, so that it’s harder to change just one thing.
5.5. Tell, Don’t Ask.
Don’t get values from an object, transform them, and then stick them back. Make the object do the work.
5.6. Don’t Chain Method Calls.
Try not to have more than one dot when you access something.
5.7. Avoid Global Data.
It’s like adding an extra parameter to every method.
5.8. If It’s Important Enough To Be Global, Wrap It in an API.
…but only if you really, really want it to be global.
5.9. Programming Is About Code, But Programs Are About Data.
All programs transform data, converting an input into an output. Start designing using transformations.
5.10. Don’t Hoard State; Pass It Around.
Don’t hang on to data within a function or module. Take one down and pass it around.
Thanks for reading, happy coding 😀
Top comments (0)