The “Rule of 10” for functions, components and modules

Tom Söderlund
1 min readJun 16, 2017

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.

--

--

Tom Söderlund

CTO. Dad. Feminist. Lover. Fan of AI 🧠, environment 🌎, lean startup 📊, surfskate 🛹, cappuccinos ☕ and movies 🎬. Still learning.