Chapter 4: The importance of loose coupling
Introduces loose coupling, defines when software elements are coupled, and explains why different forms of coupling matter to change speed and runtime behavior.
After this chapter you will be able to
- Coupling and architectural quality. Explain that two software elements are coupled when one can affect the other, and why loose coupling matters for ease of change and availability.
- Coupling types and their effects. Distinguish the two coupling types that affect development and deployment speed from the two that affect runtime behavior.
- Coupling and element influence. Explain coupling as the ability of one software element to influence another. Distinguish loose from tight coupling by the degree of influence and state why tight coupling is best avoided.
- Four types of coupling. Distinguish design-time, build-time, runtime, and infrastructure coupling by what happens when one element changes, fails, or affects shared infrastructure.
- Coupling and fast flow. Explain how loose design-time coupling and loose build-time coupling contribute to fast flow.
- Coupling and runtime behavior. Distinguish the runtime effects of tight runtime coupling from those of infrastructure coupling.
- Loose design-time coupling. Explain that services should be loosely design-time coupled so a change to one rarely affects another, and that this applies to domain-view elements as well as components.
- Design-time coupling and change impact. Explain design-time coupling as the likelihood that changing one software element requires changing another, and describe what loose coupling means for dependent subdomains.
- Cohesive grouping of software elements. Describe how cohesion groups tightly design-time coupled child elements under the same parent while keeping loosely coupled elements in different parents. Apply that principle to the Order LineItems and MenuItems example.
- Localized and safer changes. Explain why loose design-time coupling makes changes easier and safer, using the Customer Management and Order Management example.
- Autonomy across module teams. Explain how loose design-time coupling reduces coordination between teams that own different subdomains.
- Design-Time Coupling and Team Growth. Explain why loosely design-time coupled teams can be added with little extra coordination, while tightly coupled teams become harder to scale.
- Stable API design bets. Explain why designing for loose design-time coupling requires judging which concepts will remain stable and which will change. Describe how a mistaken judgment lets changes ripple through the application.
- Single representation of business rules. Explain how the DRY principle reduces the work and risk of changing a business rule, using FTGO’s order-total calculation as an example.
- Small API iceberg principle. Explain the Iceberg principle and why an API should expose much less than its implementation contains.
- Dependency direction trade-offs. Compare direct API calls and event publication for notifying other subdomains when an order is placed. Explain why reversing dependencies helps Order Management but does not eliminate coupling.
- Consumed dependency surface area. Explain why the amount of a dependency a client consumes matters, using the two launch-status designs to contrast a simple isGo() call with retrieving subsystem data.
- Build-time coupling between subprojects. Explain when one build subproject is build-time coupled to another, using the FTGO example.
- Build-time coupling and feedback. Distinguish build-time coupling’s effect on feedback time from design-time coupling’s effect on making a change, and explain why rebuilding more subprojects increases the wait.
- Dependency-driven build-time coupling. Explain how dependencies between Gradle subprojects create build-time coupling by determining which subprojects an incremental build must recompile and retest.
- Stable API project dependencies. Explain why clients should depend on a subdomain’s API subproject rather than its implementation subproject, using the Customer Management example.
- Subproject boundaries and test runs. Explain why changing one package can run unrelated tests in a single Gradle subproject, and how splitting the Customer Management Implementation project reduces that build-time coupling.
- Runtime coupling and availability. Explain when one component is runtime coupled to another and how that dependence affects an operation’s availability. Distinguish this runtime effect from design-time and build-time coupling, which affect development.
- Order request runtime dependency. Trace why the Order Service is runtime coupled to the Customer Service when handling a POST /orders request.
- Combined endpoint availability. Explain how the two-service dependency reduces availability, including the calculation and the risk of longer chains.
- Added request latency. Explain why waiting for the Customer Service increases the POST /orders response time.
- Siloed views of runtime dependencies. Explain how a request that appears straightforward to one team can depend on many services across teams, creating tight runtime coupling and an SLA risk.
- Localizing an operation by merging. Explain how merging an operation’s subdomains into one service removes runtime coupling for that operation, and why this is not a general solution.
- Relocating a service responsibility. Describe how moving available-credit management to the Order Service reduces coupling for createOrder(), including the dependency it shifts to customer creation and the approach’s limitation.
- Asynchronous order validation. Trace how asynchronous messaging lets the Order Service respond before the Customer Service validates an order, and explain what the client must do to learn the final outcome.
- Shared infrastructure runtime effects. Explain that components are infrastructure-coupled when they use the same infrastructure, and that they can negatively affect one another’s runtime behavior without communicating. State why minimizing this coupling matters especially for highly available components.
- Shared infrastructure interference. Explain why deploying Customer Service and Order Service on the same Kubernetes cluster and shared database server can let one affect the other. Describe resource competition and infrastructure configuration changes as the two potential sources of interference named here.
- Competition for shared resources. Explain how one service can impair another by consuming shared infrastructure resources, even when container CPU and memory limits are configured.
- Unintended configuration effects. Explain how a configuration change made for one service can accidentally affect another service using the same infrastructure.
- Critical service isolation. Explain how service design and deployment work together to minimize infrastructure coupling for a critical service, using the Order Service example.
What it builds on
- Why architecture matters (chapter 3) · Introduces why software architecture matters.
- Domain view (chapter 3) · Introduces the domain view.
- Component view (chapter 3) · Introduces the component view.
- About the hexagonal architecture style (chapter 3) · Introduces architectural separation between an element and its clients.
- Build view (chapter 3) · The architectural view of how an application is built.
Section by section
Introduction
Introduces loose coupling, defines when software elements are coupled, and explains why different forms of coupling matter to change speed and runtime behavior.
- Coupling and architectural quality: Explain that two software elements are coupled when one can affect the other, and why loose coupling matters for ease of change and availability.
Why it matters: This gives you a way to recognize why dependencies between elements can become an architectural problem. - Coupling types and their effects: Distinguish the two coupling types that affect development and deployment speed from the two that affect runtime behavior.
Why it matters: The distinction helps you identify whether a coupling problem primarily slows delivery or affects the running application.
Key terms: coupling, loose coupling, tight coupling, availability, ease of change, design-time coupling, build-time coupling, runtime coupling, infrastructure coupling, fast flow
4.1 Introduction to coupling
Defines coupling in terms of influence between software elements and explains why loose coupling is desirable.
- Coupling and element influence: Explain coupling as the ability of one software element to influence another. Distinguish loose from tight coupling by the degree of influence and state why tight coupling is best avoided.
Why it matters: This definition gives you a starting point for recognizing why some relationships between software elements are more troublesome than others.
Key terms: coupling, loose coupling, tight coupling, software elements
4.1.1 Four flavors of coupling
The section defines four types of coupling and distinguishes their development-time and runtime effects.
- Four types of coupling: Distinguish design-time, build-time, runtime, and infrastructure coupling by what happens when one element changes, fails, or affects shared infrastructure.
Why it matters: These distinctions help you identify what kind of dependency exists between elements. - Development and runtime effects: Explain which types of coupling influence development-time characteristics and which affect an application’s runtime behavior.
Why it matters: The grouping shows whether a coupling concern arises during development or while the application runs.
Key terms: design-time coupling, build-time coupling, runtime coupling, infrastructure coupling, development-time characteristics, runtime behavior
4.1.2 Why loose coupling matters
This section explains why loose design-time and build-time coupling support fast flow, while runtime and infrastructure coupling affect an application’s behavior in production.
- Coupling and fast flow: Explain how loose design-time coupling and loose build-time coupling contribute to fast flow.
Why it matters: These are the forms of coupling the section connects directly to faster software delivery. - Coupling and runtime behavior: Distinguish the runtime effects of tight runtime coupling from those of infrastructure coupling.
Why it matters: Separating these effects helps explain whether a coupling concern is about delivery speed or behavior in production.
Key terms: design-time coupling, build-time coupling, fast flow, deployment pipeline, runtime coupling, infrastructure coupling, availability, latency
4.2 Design-time coupling
This section introduces loose design-time coupling as a reason microservices support fast flow and identifies where that coupling matters.
- Loose design-time coupling: Explain that services should be loosely design-time coupled so a change to one rarely affects another, and that this applies to domain-view elements as well as components.
Why it matters: Keeping changes from spreading across elements is a key reason microservices can support fast flow.
Key terms: design-time coupling, component view, domain view, fast flow
4.2.1 Design-time coupling and cohesion
This section explains how loose design-time coupling and cohesion organize software elements so changes remain localized and easier to make.
- Design-time coupling and change impact: Explain design-time coupling as the likelihood that changing one software element requires changing another, and describe what loose coupling means for dependent subdomains.
Why it matters: This gives you a way to judge whether a dependency is likely to spread future changes. - Cohesive grouping of software elements: Describe how cohesion groups tightly design-time coupled child elements under the same parent while keeping loosely coupled elements in different parents. Apply that principle to the Order LineItems and MenuItems example.
Why it matters: Cohesion provides a way to contain changes that cannot be confined to a single class or subdomain. - Benefits of localized changes: Explain how loose coupling and cohesion make changes easier by limiting the other elements, code, and teams a change must involve.
Why it matters: Keeping unrelated work out of a change reduces the effort and coordination needed to make it.
Key terms: design-time coupling, loose design-time coupling, subdomain, cohesion, child elements, parent element, LineItems, MenuItems, localized changes, independently and in parallel
4.2.2 Benefits of loose design-time coupling
This section explains how loose design-time coupling localizes changes, increases team autonomy, and supports business success.
- Localized and safer changes: Explain why loose design-time coupling makes changes easier and safer, using the Customer Management and Order Management example.
Why it matters: The fewer parts a change touches, the easier it is to make without unintended consequences. - Autonomy across module teams: Explain how loose design-time coupling reduces coordination between teams that own different subdomains.
Why it matters: Teams can finish changes faster when they do not routinely depend on another team’s work. - Coupling and business success: Describe the link this section draws between loose design-time coupling, high-performing development organizations, and business success.
Why it matters: The section connects a software-design choice to the ability of development teams to contribute to business results.
Key terms: loose design-time coupling, cohesion, localized change, team autonomy, coordination, business success, high performing organizations
4.2.3 Loose design-time coupling enables organizations to scale
This section explains how design-time coupling affects communication overhead and an organization’s ability to grow without slowing delivery.
- Design-Time Coupling and Team Growth: Explain why loosely design-time coupled teams can be added with little extra coordination, while tightly coupled teams become harder to scale.
Why it matters: Adding teams helps only if coordinating their work does not consume the added capacity. - Communication Costs and Delivery Performance: Describe how the Brooks observation and the Accelerate findings illustrate different outcomes when organizations add people.
Why it matters: These observations show why more developers do not automatically mean faster delivery.
Key terms: design-time coupling, communication overhead, loosely coupled architecture, tightly design-time coupled architecture, Fred Brooks, Accelerate, deployments per day per developer
4.2.4 Designing loosely design-time coupled software
The section explains design choices that reduce design-time coupling by keeping APIs stable, avoiding harmful duplication, and limiting what software elements expose and depend on.
- Stable API design bets: Explain why designing for loose design-time coupling requires judging which concepts will remain stable and which will change. Describe how a mistaken judgment lets changes ripple through the application.
Why it matters: A stable boundary lets implementation changes stay local instead of spreading to clients. - Single representation of business rules: Explain how the DRY principle reduces the work and risk of changing a business rule, using FTGO’s order-total calculation as an example.
Why it matters: A rule that looks settled can change, turning convenient copies into costly, error-prone maintenance. - Limits of applying DRY: Distinguish harmful duplication from situations where duplication may be acceptable, and explain how one shared implementation can itself create undesirable dependencies.
Why it matters: Eliminating every duplicate can trade one maintenance problem for a dependency that slows teams down. - Small API iceberg principle: Explain the Iceberg principle and why an API should expose much less than its implementation contains.
Why it matters: The less an element exposes, the more freedom it has to change internally. - Dependency direction trade-offs: Compare direct API calls and event publication for notifying other subdomains when an order is placed. Explain why reversing dependencies helps Order Management but does not eliminate coupling.
Why it matters: Changing dependency direction can protect one team’s autonomy while shifting change risk to others. - Consumed dependency surface area: Explain why the amount of a dependency a client consumes matters, using the two launch-status designs to contrast a simple isGo() call with retrieving subsystem data.
Why it matters: Even a necessary dependency can remain loose when the client uses only a small, stable part of it.
Key terms: design-time coupling, API, implementation details, monolith-first approach, DRY, Don’t Repeat Yourself, OrderTotalCalculator, order total, shared library, team autonomy
4.3 Build-time coupling
This section defines build-time coupling between build subprojects and explains how it lengthens the wait for build and test feedback.
- Build-time coupling between subprojects: Explain when one build subproject is build-time coupled to another, using the FTGO example.
Why it matters: This definition lets you recognize coupling by its effect on an unchanged subproject. - Build-time coupling and feedback: Distinguish build-time coupling’s effect on feedback time from design-time coupling’s effect on making a change, and explain why rebuilding more subprojects increases the wait.
Why it matters: Extra rebuilds and tests can slow the feedback a developer gets after making a change.
Key terms: build-time coupling, build project, build subproject, recompiled and retested, design-time coupling, feedback
4.3.1 About build-time coupling in Gradle projects
This section explains how dependencies between Gradle subprojects determine which projects an incremental build recompiles and retests after a change.
- Dependency-driven build-time coupling: Explain how dependencies between Gradle subprojects create build-time coupling by determining which subprojects an incremental build must recompile and retest.
Why it matters: This explains why a dependency can make a change increase build and test work elsewhere. - Direct and transitive build effects: Trace the subprojects affected by changes to Money and Customer in the FTGO example, including order-management’s transitive dependency on money.
Why it matters: The example shows that the direction and reach of dependencies determine a change’s build impact.
Key terms: Gradle build project, subprojects, incremental builds, build-time coupling, Money, Customer, implementation dependency, api dependency, transitive dependency
4.3.2 A project should only be build-time coupled to stable projects
This section shows how separating a subdomain’s stable API from its frequently changing implementation reduces build-time coupling and speeds builds.
- Stable API project dependencies: Explain why clients should depend on a subdomain’s API subproject rather than its implementation subproject, using the Customer Management example.
Why it matters: Depending on a stable API avoids unnecessary client build and test work when an implementation changes.
Key terms: build-time coupling, API subproject, implementation subproject, CustomerService
4.3.3 Reducing build-time coupling within a Gradle subproject
The section shows how splitting a Gradle subproject along dependency boundaries can avoid unnecessary test runs, especially in a large monolith.
- Subproject boundaries and test runs: Explain why changing one package can run unrelated tests in a single Gradle subproject, and how splitting the Customer Management Implementation project reduces that build-time coupling.
Why it matters: Choosing subproject boundaries can spare a build from running slow tests for unaffected code.
Key terms: build-time coupling, Gradle subproject, web, persistence, domain
4.4 Runtime coupling
The section defines runtime coupling and explains why a service’s dependence on another service’s response can make a distributed operation unavailable.
- Runtime coupling and availability: Explain when one component is runtime coupled to another and how that dependence affects an operation’s availability. Distinguish this runtime effect from design-time and build-time coupling, which affect development.
Why it matters: Recognizing a response dependency helps explain why an otherwise working service may fail to complete an operation.
Key terms: runtime coupling, design-time coupling, build-time coupling, availability
4.4.1 An example of tight runtime coupling
The Order Service example shows how waiting for another service at runtime reduces endpoint availability and increases response time.
- Order request runtime dependency: Trace why the Order Service is runtime coupled to the Customer Service when handling a POST /orders request.
Why it matters: The wait between services creates the availability and latency effects illustrated here. - Combined endpoint availability: Explain how the two-service dependency reduces availability, including the calculation and the risk of longer chains.
Why it matters: An endpoint can be less available than any one service it depends on. - Added request latency: Explain why waiting for the Customer Service increases the POST /orders response time.
Why it matters: A dependent service's response time becomes part of the caller's response time.
Key terms: runtime coupled, Order Service, Customer Service, POST /orders, PUT /customers/{id}, availability, long chains, latency, response time, tight runtime coupling
4.4.2 Siloed organization can lead to tight runtime coupling
Shows how a siloed view of a request can hide tight runtime coupling and put an SLA at risk.
- Siloed views of runtime dependencies: Explain how a request that appears straightforward to one team can depend on many services across teams, creating tight runtime coupling and an SLA risk.
Why it matters: A team's view of its own services may miss dependencies that threaten the reliability of the whole request.
Key terms: tight runtime coupling, end-to-end flow of requests, SLA
4.4.3 Minimizing runtime coupling
This section explains three ways to reduce an operation’s runtime coupling and the trade-offs each introduces.
- Localizing an operation by merging: Explain how merging an operation’s subdomains into one service removes runtime coupling for that operation, and why this is not a general solution.
Why it matters: Making a critical operation local can improve its availability and latency, but it changes the size and boundaries of the service. - Relocating a service responsibility: Describe how moving available-credit management to the Order Service reduces coupling for createOrder(), including the dependency it shifts to customer creation and the approach’s limitation.
Why it matters: Changing which service owns a responsibility can improve a critical operation while shifting the cost to a less critical one. - Asynchronous order validation: Trace how asynchronous messaging lets the Order Service respond before the Customer Service validates an order, and explain what the client must do to learn the final outcome.
Why it matters: An immediate response can make order creation more available, but clients must not mistake it for a final decision.
Key terms: runtime coupling, subdomains, Order Service, createOrder(), available credit, Customer Service, subdomain, asynchronous messaging, POST /orders, partial outcome
4.5 Infrastructure coupling
This section defines infrastructure coupling and explains why sharing infrastructure can affect components’ runtime behavior even when they do not communicate.
- Shared infrastructure runtime effects: Explain that components are infrastructure-coupled when they use the same infrastructure, and that they can negatively affect one another’s runtime behavior without communicating. State why minimizing this coupling matters especially for highly available components.
Why it matters: Components can affect each other’s availability through shared infrastructure even when they have no communication dependency.
Key terms: infrastructure coupling, runtime behavior, infrastructure, highly available components
4.5.1 An example of infrastructure coupling
Uses two services sharing infrastructure to show how infrastructure coupling can let one service affect another.
- Shared infrastructure interference: Explain why deploying Customer Service and Order Service on the same Kubernetes cluster and shared database server can let one affect the other. Describe resource competition and infrastructure configuration changes as the two potential sources of interference named here.
Why it matters: Sharing infrastructure can make one service’s behavior or infrastructure changes a problem for another service.
Key terms: infrastructure coupling, shared infrastructure, Customer Service, Order Service
4.5.2 Two types of infrastructure coupling
This section explains two ways services can be coupled through shared infrastructure: competing for resources and being affected by each other’s configuration changes.
- Competition for shared resources: Explain how one service can impair another by consuming shared infrastructure resources, even when container CPU and memory limits are configured.
Why it matters: Resource limits do not eliminate every way shared infrastructure can let one service disrupt another. - Unintended configuration effects: Explain how a configuration change made for one service can accidentally affect another service using the same infrastructure.
Why it matters: Services can affect each other through infrastructure changes even without competing for resources.
Key terms: competition for resources, Kubernetes, CPU and memory resources, network bandwidth, database resources, database lock, configuration changes with unintended consequences, Kubernetes cluster, database server
4.5.3 Minimizing infrastructure coupling
This section explains how runtime decoupling and separate infrastructure can improve the availability of critical services.
- Critical service isolation: Explain how service design and deployment work together to minimize infrastructure coupling for a critical service, using the Order Service example.
Why it matters: Separating both service dependencies and infrastructure helps keep critical requests available when other services encounter problems. - Coupling effects by type: Distinguish the kinds of coupling that affect runtime behavior from those that affect the development experience.
Why it matters: This distinction clarifies whether a coupling problem primarily affects the running application or the work of changing it.
Key terms: infrastructure coupling, runtime decoupled, critical services, separate infrastructure, Order Service, runtime coupling, design-time coupling, build-time coupling
4.6 Summary
Where this is used later
- Modifiability requires loose design-time coupling and high cohesion (chapter 5) · Connects loose design-time coupling to modifiability.
- Comparing two definitions of the microservice architecture (chapter 7) · Introduces the concept of coupling.
- Running testing locally (chapter 5) · The value of reducing dependencies between parts of an application.
- Testable using automated tests (chapter 5) · The discussion of design-time coupling provides context for loosely coupled elements.
- Domain module design (chapter 6) · The benefits of loose design-time coupling.
- Enables fast, sustainable flow (chapter 7) · The benefits of loose design-time coupling.
- Defining APIs in a microservice architecture (chapter 8) · Uses the value of loose design-time coupling between elements.
- Enables an organization to scale (chapter 7) · Connects loose coupling to the ability of an organization using microservices to scale.
Concepts explained in this chapter
- loose couplingAn architectural property in which software elements have limited dependencies on one another, allowing them to change more independently.
- cohesionCohesion is the degree to which the elements or responsibilities within a software component belong together.
- runtime couplingA strong runtime dependency in which one component's failure or unavailability prevents another from completing its operation.
- infrastructure couplingInfrastructure coupling is a dependency in which services are affected by shared deployment infrastructure, infrastructure resources, or infrastructure configuration changes.
- don't repeat yourself principleA design principle requiring each piece of knowledge in a system to have a single, unambiguous, authoritative representation.
- iceberg principleA software design principle in which an element exposes a small API relative to the larger implementation that it hides.
- design-time couplingThe degree to which software elements must be designed or changed together because of dependencies between them.
- build-time couplingLoose build-time coupling is a build dependency property in which changing a build module requires relatively few other subprojects to be recompiled and retested.
- tight couplingA relationship in which software elements have substantial dependencies on one another.
- couplingCoupling is a dependency between software elements in which changes, failures, or shared resources in one element can affect another.
- Gradle subprojectA Gradle subproject is an independently configurable project within a larger Gradle build, with its own source code, dependencies, and build tasks.
- asynchronous communicationA messaging technique in which a sender continues processing without waiting for an immediate reply.
- autonomyTeam autonomy is a team property in which the team can perform its work with minimal dependence on coordination, hand-offs, or waiting on other teams.
- Gradle ProjectA configuration and set of tasks that transforms source code into compiled or packaged software artifacts.
- GradleAn open-source build automation system that models builds as tasks and supports dependency management and incremental execution.
- availabilityThe degree to which a system or service is operational and accessible when required.
- latencyLatency is the elapsed time between initiating an operation and receiving its result or response.
- incremental buildAn incremental build is a build process that recompiles, retests, or repackages only software elements affected by changes.
- transitive dependencyA dependency introduced indirectly through another dependency rather than declared directly by the application.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
