Design-time coupling is the likelihood that a change to one software element will require a change to another. Loose coupling localizes changes, making them easier to implement and supporting team autonomy and fast flow. Some coupling is inevitable, and eliminating it can have significant drawbacks. section 4.1.1 section 4.6
Coupling matters at several levels: classes, packages, subdomains, and components. Organize these elements to minimize coupling between them while managing unavoidable dependencies through cohesion. A cohesive package, for example, can contain tightly coupled classes while remaining loosely coupled to other packages. section 4.2 section 4.2.1
Figure 4.2 You can localize changes, which improves maintainability, by designing loosely coupled packages that are internally cohesive by virtue of being comprised of tightly coupled classes
The figure illustrates how cohesive packages can localize changes while remaining loosely coupled to one another. section 4.2.1
Coordinating a breaking API change
A breaking change to Consumer Service’s API would break clients such as Order Service. Instead of replacing the API immediately, add a new version alongside the old one, have client teams migrate, and remove the old version once migration is complete. This coordination illustrates the cost of design-time coupling across services and teams. section 7.3.2
In a microservice architecture, tightly coupled services can form a distributed monolith: services must change in lockstep despite being distributed. Define service boundaries carefully and watch for changes that repeatedly cross those boundaries. Loose coupling supports modifiability, but it does not remove every dependency or coordination cost. section 7.3.2 section 1.3.4
Distinguish design-time coupling from other forms of coupling:
- Build-time coupling requires another element to be recompiled and retested after a change. section 4.1.1
- Runtime coupling allows one element’s failure to cause another to fail. section 4.1.1
- Infrastructure coupling occurs when elements share infrastructure and one element’s behavior affects the other. section 4.1.1
