- **Epistemic status:** #evergreen ![[modularization.svg]] Modularity in software development is the amount of components in a system that can be divided into smaller sub-systems and then re-combined in a variety of configurations. These components have varied levels of dependence and independence, hiding the complexity behind a standardized interface or API. By using the interface, the components are able to interact, connect or exchange resources with each other. A modular system is attributed as a “loosely coupled” since each component does not contain any other particular component as a dependency to be able to function. As these components evolve or are replaced, it does not affect the overall system. A properly documented component with a clean API makes it easy to redesign without having a deep understanding of the overall system. It is imperative that when designing a component to emphasize simplicity over complexity, making each component small and easy to read. The benefits of building such a system are: - **Reusability:** You can re-use components in the same system or other systems multiple times - **Flexibility:** Saves resources by not having to re-create a component to assemble a new system and improves collaboration in a team since they can focus on individual parts without affecting the others - **Testability:** Components with isolated dependencies and a clear API makes them highly testable ensuring quality of the overall system - **Healthy:** Diseased sections of code are isolated disallowing symptoms to spread around the rest of the system. It is also easier to cut it out and replace it with a healthier and newer one - **Durability:** Making changes to one module would only generate problems, if any, in the module itself, resulting in a system that is less fragile. [[Tim Berners-Lee]] described the principle in Axioms of Web Architecture [[#^8e7669]] in favor of building a modular system: > "When you design a system, or a language, then if the features can be broken into relatively loosely bound groups of relatively closely bound features, then that division is a good thing to be made a part of the design. This is just good engineering. It means that when you want to change the system, you can with luck in the future change only one part, which will only require you to understand (and test) that part. This will allow other people to independently change other parts at the same time. " Let's understand this concept with an example: You were tasked with building a wiki for a company to digitize their internal documents. They have over a 1000 pages. You might think "A thousand! That sounds challenging!". The reality is that the pages consist of a few layouts such as user management, login, creating new documents, and reading new documents. The project's level of effort is determined by the functionality and components contained within those pages, rather than on the quantity of pages themselves. Another key principle when implementing modularity is the [[Principle of Least Privilege]] that by limiting the scope of the module you minimize the amount of damage a vulnerability can do to the system on the resources it can access. As you design a new system, keeps this principle in mind and build a library of components that can make each iteration easier. --- ## References - “Atomic Design by Brad Frost.” Accessed Apr 11, 2022. <http://atomicdesign.bradfrost.com/>. - “Design Issues.” Accessed October 20, 2021. <https://www.w3.org/DesignIssues/Modularity.html>. - “Axioms of Web Architecture.” Accessed October 20, 2021. <https://www.w3.org/DesignIssues/Principles.html>. ^8e7669 - Khan, Al. “Zettelkasten Method: How to Take Smart Notes (A Beginner’s Guide).” LEANANKI, May 20, 2020. <https://leananki.com/zettelkasten-method-smart-notes/>. - “Modularity.” In _Wikipedia_, August 5, 2021. <https://en.wikipedia.org/w/index.php?title=Modularity&oldid=1037275944>. - “The Advantages of Modular Software and Programming – Gwentech Embedded.” Accessed October 20, 2021. <https://gwentechembedded.com/the-advantages-of-modular-software-and-programming/>. - [www.javatpoint.com](http://www.javatpoint.com). “What Is Modular Programming - Javatpoint.” Accessed October 20, 2021. <https://www.javatpoint.com/what-is-modular-programming>. - Techopedia.com. “What Is Modularity? - Definition from Techopedia.” Accessed October 20, 2021. <http://www.techopedia.com/definition/24772/modularity>. - Thomas, David, and Andrew Hunt. _The Pragmatic Programmer, 20th Anniversary Edition: Journey to Mastery_. Second edition. Boston: Addison-Wesley, 2019.