“95% of the words are spent extolling the benefits of ‘modularity’ and that little, if anything, is said about how to achieve it.” — Glenford J. Myers
Modularity, like complexity, is a term we intuitively understand. But do we really? What exactly is modularity? What makes a system modular?
The Opposite of Complexity
If complexity is a system design that makes it impossible to predict the outcomes of actions or changes, then modularity is the opposite. Modular design ensures that the outcomes of actions and changes are clear. When implementing new functionality or modifying an existing one, modular design can be illustrated in two key points:
- Modular design makes it clear what part of the system needs to change.
- Modular design makes the outcome of the change clear and predictable.
This definition of modularity can be described from a higher level of abstraction: system goals.
Goals
A system is a set of components interacting to achieve a set of goals. For example, a goal can be the business functionality the system has to implement. Non-functional requirements—such as scalability, availability, and other “-ilities”—are goals as well.
From a system design perspective, even the most chaotic “big ball of mud” can still achieve its goals. As long as it works—even if no one knows how—the system is said to fulfill its objectives. Modular design, however, extends a system’s goals into the future.
Future Goals
A software system that provides value to its users will inevitably change. New functionalities will be added, existing ones will be adapted, and some will be removed. Change is inherent in healthy systems. Modular design expands the system’s goals beyond its current requirements by ensuring that future changes are easy to implement.
This doesn’t mean a system should preemptively implement all possible future requirements—that’s impossible. Instead, it should make the implementation of reasonable changes easy. Again, this contrasts with complexity: we aim to design the system in a way that minimizes the cognitive load needed to make a change.
This makes complexity and modularity contrasting concepts. Such a relationship suggests they share a fundamental cause—one that determines whether a system is modular or complex. That cause is coupling.