Practices - Do you write small components?

Updated by Caleb Williams [SSW] 1 year ago. See history

123
<introEmbed body={<> The Single Responsibility Principle is a well understood, and well-accepted tenet of good code design. It states that a class should do one thing, and do it well - The same applies to Components used with Frameworks such as Angular, React, Vue and Blazor. 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. </>} />
Image

❌ Figure: Bad example - Having just 3 components for the page makes it difficult to reuse, maintain and test

Image

✅ 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

Acknowledgements

Steve Leigh
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star