liveBook · Manning

Design-time coupling

As explained in Microservices Patterns, Second Edition

The degree to which software elements must be designed or changed together because of dependencies between them.

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
improving cohesion order menu

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

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines coupling across a hierarchy of software elements and explains cohesion, change localization, and coordinated API migration.
Examples
Illustrates an Order Management dependency on Delivery Management and a staged Consumer Service API migration.
What you can do after
Evaluate service boundaries and change coordination for signs of tight design-time coupling.
How it connects
Connects cohesion, microservice architecture, distributed monoliths, and build-time, runtime, and infrastructure coupling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.