The “Rule of 10” for functions, components and modules
2017-06-16
Here’s my “Rule of 10” for functions, components and modules:
- If a function has >10 lines of code, break out into multiple functions.
- If a component has >10 functions, break out into multiple components.
- If a module has >10 components, break out into multiple modules.
Update 1: I break these rules on a daily basis…
Update 2: Something I noticed recently, is that when I break up my code in micro functions, it’s much easier to spot repetitive and redundant code. I aim for tiny functions calling other tiny functions.