Book Deep Read · Fundamentals of Software Architecture · Chapter 3
Fundamentals of Software Architecture · Ch 3 · Mark Richards & Neal Ford · 2020
Everyone says code should be "modular" — split into pieces. But ask "is this a good split?" and most people can only answer from gut feeling. Chapter 3 tries to turn that feeling into something you can count and compare: do the things inside one chunk of code really belong together? How tangled are the chunks with each other? If you change one spot, how many other spots must change with it?
When you move, you put the dishes in one box, the books in another, the clothes in a third. Everything in a box is related — the box "hangs together." And when you unpack, you don't have to hunt all over the house — the boxes "don't tangle." The worst box is the junk box: a remote, a sock and a screwdriver, together only because they happened to share a drawer. Code has junk boxes too, and the book ranks them dead last.
A room you never tidy gets messier, and code is the same. Today, in a rush, someone reaches into the guts of the neighboring module; tomorrow, someone does it again. Over time the lines between modules knot into a tangle. The authors put it bluntly: keeping things modular takes constant effort; it does not maintain itself.
The first ruler measures how tightly a module hangs together: does everything inside revolve around one job? One clue is whether the pieces share the same data. If half the functions only touch one thing and the other half only touch another, it is really two modules squeezed into one.
The second measures how tangled it is with others: how many modules lean on it, and how many it leans on. Think of a coworker whom dozens of colleagues depend on — when they take a day off, the whole floor stalls. Or the opposite: a role nobody depends on, but which relies on ten other people, so it has to change every time any of them does.
The third and finest is called "born together": if you change A, you must also change B, or the system goes wrong. Say two forms agree that "the first box is the seat number, the second is the name." Fill them in backwards and nothing complains — things just quietly break. The more hidden such an agreement and the farther apart the two sides, the more dangerous it is. Hence the rule: the farther apart two pieces are, the simpler and more obvious their agreement must be; keep the complicated entanglements inside one module.
With these three rulers, "is this a good split?" stops being an argument and becomes a measurement. The "powder keg" everyone depends on and nobody dares touch, the empty shell no one uses — both stand out, and a tool can check for them every day. One honest cost: the rulers see structure, not business meaning — whether two things truly belong together is still a call for someone who understands the domain.
A good module = tight inside, loose outside, and the farther apart, the simpler the agreement — and that tidiness needs daily upkeep.
Want the seven levels of cohesion, instability and the "main sequence" chart, and the nine forms of connascence? → Switch to Deep
You think modularity is a matter of taste; it is actually measurable. FoSA Chapter 3 hands architects three rulers — cohesion for what happens inside a module, coupling for what happens between modules, and connascence for "how many other places must change when I change this one" — and warns that modularity is a fight against software entropy: stop spending effort and it decays.
The third chapter of Part I, "Foundations," right after Chapter 2, "Architectural Thinking." The first two chapters cover how an architect thinks; this one provides the first measurable toolkit. Chapter 7's "architecture quantum" pushes connascence to the distributed level, and Chapter 8 promotes modules into components. In practice: dependency analysis before breaking up a monolith, and every code-review argument about "does this belong here?"
Nearly every platform supports modularity (packages, namespaces, the module system since Java 9), yet "what is a good split" has long stayed a matter of instinct. The consequences are concrete: a utility package that 30 other packages depend on, written entirely as concrete code, forces a wide regression run for every one-line change; a "utility class" keeps growing until everything gets dumped into it. The authors' view is that software naturally drifts toward disorder — good structure needs a steady input of energy — and to spend that energy in the right direction, you first need to quantify "good" and "bad." The chapter invents no new theory. It gathers decades of scattered measures — cohesion and coupling from the structured-design era, Robert Martin's package metrics, Page-Jones's connascence — into a vocabulary for architects.
Cohesion is the degree to which the parts of a module belong in the same module. The book uses the classic seven-level scale, best to worst:
StringUtils full of assorted static methods.The book's example: a Customer Maintenance module offers add, update, get and notify customer — plus "get customer orders" and "cancel customer orders." Should those last two move into a separate Order Maintenance module? The answer is it depends. Would Customer Maintenance be left with only two or three operations, too thin to stand alone? Would Order Maintenance need so much customer information that splitting creates a web of new dependencies? Judging cohesion is really a trade between module size and coupling between modules.
To make it computable, the book brings in an object-oriented metric, LCOM (Lack of Cohesion in Methods). In plain terms: count how many groups of methods in a class share no fields with each other.
LCOM is good at catching classes that look like one but are really two or three. The book is equally frank about its limit: it sees structure, not meaning — two methods that share no fields may still belong together in business terms.
Coupling metrics go back to Yourdon and Constantine's Structured Design (1979): afferent coupling (Ca) counts incoming connections — how much outside code depends on me; efferent coupling (Ce) counts outgoing ones — how much outside code I depend on. On top of these, Robert Martin derived three package-level metrics:
A): the ratio of abstract classes and interfaces to all classes. Code stuffed into one giant main() has abstractness near 0.I = Ce / (Ce + Ca)): in plain terms, "what share of my dependency relationships point outward." Near 1: nobody depends on me but I depend on lots — easy to change, but I break when others change. Near 0: everyone depends on me — change one line and the ripple is wide.D = |A + I − 1|): the ideal package sits on the line A + I = 1 — the more depended on, the more abstract it should be; the more concrete, the fewer dependents it should have. The closer D is to 0, the healthier.A worked example: a utility package depended on by 8 packages (Ca=8) and depending on only 2 (Ce=2) has I = 2/10 = 0.2. If it has no interfaces at all (A=0), then D = |0 + 0.2 − 1| = 0.8 — deep in the zone of pain. The fix is not necessarily to split the package but to make dependencies point at abstractions: extract interfaces, let the 8 callers know only the interface, push the concrete implementation behind it; A rises and D falls. All of this can be computed by a tool every night, which makes it raw material for Chapter 6's fitness functions.
In 1996 Meilir Page-Jones introduced connascence (literally "born together"): two components are connascent if a change in one would require the other to be modified to keep the system correct. It is far finer-grained than "depends / doesn't depend," and it comes in two families.
Static connascence (visible in source code): name (callers must know the method name), type (types must agree), meaning / convention (e.g. agreeing that 1 means true; magic numbers), position (argument order — the book's example is updateSeat("14D", "Ford, N"): both are strings, so swapping them never trips the compiler), and algorithm (client and server must use the same hashing algorithm to verify data).
Dynamic connascence (exposed only at runtime): execution order (you must set the recipient before calling send()), timing (the order of two threads decides the result — a race condition), values (several values must change together; especially common in distributed transactions), and identity (several components must reference the same entity, such as jointly updating one distributed queue).
Connascence also has three properties: strength — the easier it is to refactor away, the weaker it is, and static is generally weaker than dynamic; locality — connascence within one module is far more acceptable than across modules; and degree — how many classes it touches, so strong connascence with a small blast radius is sometimes tolerable. Page-Jones offered three guidelines: minimize overall connascence by breaking the system into encapsulated elements; minimize any remaining connascence that crosses encapsulation boundaries; maximize connascence within encapsulation boundaries. Jim Weirich compressed this into two memorable rules: the Rule of Degree (convert strong forms into weaker forms) and the Rule of Locality (as the distance between elements grows, use weaker forms).
Connascence of position is the textbook "downgrade": change updateSeat(seat, name) to take an object with named fields, or replace the bare string with a SeatNumber type. Position drops to name or type connascence, and a swapped argument is caught by the compiler on the spot.
The book points out that the structured-design coupling categories (data, stamp, control coupling and so on) line up with connascence — connascence is really a finer, more object-oriented vocabulary for coupling. But both were born in a single-process, object-oriented world and do not address key concerns of modern distributed architectures, such as whether services talk synchronously or asynchronously, or who owns which data. That is why the authors introduce the architecture quantum in Chapter 7: the cluster of things that must deploy and fail together becomes the unit of measure at the distributed level.
Table 1 · Three rulers: what each measures, how to use it, what it can't see
| Cohesion (LCOM) | Coupling (Ca/Ce/A/I/D) | Connascence | |
|---|---|---|---|
| Measures | Inside one class / module | Between packages | Any two places in code, including across services |
| Automatable? | Yes, static analysis | Yes, per-package reports | Partly for static forms; dynamic forms mostly need humans |
| Good at finding | Classes that are several-in-one | Packages stuck in the zone of pain | Hidden cross-boundary agreements (argument order, shared algorithms) |
| Blind spot / cost | Can't read business meaning | Gameable by adding interfaces; A is hard in dynamic languages | Subjective, hard to quantify; ignores sync vs. async |
Table 2 · Split or merge a module (the Customer Maintenance example)
| Split out Order Maintenance | Keep it in Customer Maintenance | |
|---|---|---|
| Cohesion | Each module is purer | Customer module carries order logic |
| Coupling | If orders need customer data often, many new cross-module dependencies | Dependencies stay inside; good locality |
| Module size | Customer module may shrink to two or three operations | One bigger module, at risk of drifting toward logical cohesion |
| Choose when | Order logic changes independently and needs little customer info | Few order operations, heavily tied to customer context |
Table 3 · Connascence strength × distance: what you can live with
| Inside one module (near) | Across modules / services (far) | |
|---|---|---|
| Weak (name, type) | Fine | Acceptable: this is the contract |
| Medium (meaning, position, algorithm) | Acceptable, keep an eye on it | Refactor: named parameters, types, shared libraries |
| Strong (execution, timing, values, identity) | Encapsulate in one place, cover with tests | Most dangerous: e.g. cross-service distributed transactions — eliminate where possible |
These metrics are not academic: for more than two decades they have been turned into tools and wired into build pipelines. The rise of the "modular monolith" is, at heart, using these rulers to defend module boundaries without splitting into services.
I = Ce / (Ce + Ca), and "the perpendicular distance of a package from the idealized line A + I = 1." Its stated goal: to automatically measure the quality of a design in terms of its extensibility, reusability, and maintainability. clarkware/jdepend · docs/JDepend.html (GitHub) ↗For interviews and reviews: asked "why is this service boundary drawn here?", being able to say "who depends on it, what it depends on, and which level of connascence crosses the boundary" is far more convincing than "it felt high-cohesion, low-coupling."
A and lowers D, but an interface with no need for polymorphism is just noise. The metrics are a health check, not a KPI.① Modularity fights entropy: without continuous effort, structure decays.
② Seven levels of cohesion: functional > sequential > communicational > procedural > temporal > logical > coincidental; a StringUtils-style utility class is logical cohesion.
③ LCOM counts "groups of methods sharing no fields" — it catches several-in-one classes but can't read meaning.
④ Ca = who depends on me, Ce = whom I depend on; I = Ce/(Ce+Ca), D = |A+I−1|, closer to 0 is healthier.
⑤ Zone of pain = concrete and heavily depended on; zone of uselessness = abstract and unused. Fix: point dependencies at abstractions.
⑥ Connascence: change A, must change B. Five static forms (name, type, meaning, position, algorithm) are weaker than four dynamic ones (execution, timing, values, identity).
⑦ Three properties: strength, locality, degree; Weirich's two rules — strong to weak, and the farther apart, the weaker.
⑧ Splitting a module trades module size against inter-module coupling; the answer is often "it depends."
⑨ These metrics are blind to distributed concerns (sync vs. async, data ownership); Chapter 7's architecture quantum fills the gap.