Keys to writing clean functions
- How easy would it be to unit test the function
- How many lines are in a function, if it greater than 20 lines then it might be doing too many things
- What are the logical steps each function is performing, if the description is "do A then B then C", then it can probably be split into 3 functions
- Data fetching -> Data processing/transformation -> Data visualization
Clean Code Practice
- DRY Principle
- Minimize entities, classes, functions
- It should be readable and simple
- Be testable
- SOLID Principle
- Careful with dependencies, should be one directional
- Don't hardcode