Do you write small components?
  v2.0 Posted at 26/04/2016 4:30 AM by Tiago Araujo

The Single Responsibility Principle  is a well understood, and well-accepted tenant of good code design.  It states that a class should do one thing, and do it well – and an Angular2 component is no exception.

When designing components, keep them small, modular and reusable. For example, if you have a menu, put it into a menu component, don’t put it in your app component.

Figure: Bad example - Having just 3 components for the page makes it difficult to reuse, maintain and test.
Figure: Good example - Splitting up the page into 11 components means they are small and targeted - and thus easy to maintain and test. Components can be reused on other pages

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:


    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.