Measuring Volatility and Ordering Components
How the book turns volatility into a number, from commit counts to composite scores, and when a volatility-respecting order exists.
Most architectural principles fail the same way: they are agreed in a meeting and forgotten in a sprint. Volatility-based decomposition survives because its three rules share one trait. Each one is short enough to remember, and the last one is built so that nobody has to. Here is what the rules say, and why the third matters most.
Group code by how often it changes. Not by feature, not by who owns it, not by the technology involved. The book's wording is that volatility is the primary decomposition axis, and it asks you to answer one question honestly across the whole system: how frequently does this component change? The natural seams show up in the answers.
Take a ride-hailing app. Fare rules move with local regulation, perhaps once a quarter. Driver-matching heuristics get tuned monthly. The rider's booking screen is nudged every week by the product team. These three all concern "a ride", yet they have almost nothing in common as far as change is concerned.
A component may depend on anything at least as stable as itself, and on nothing that is more volatile. The booking screen may use the fare rules. The fare rules may not use the booking screen.
The reason is asymmetry. When a fast component depends on a slow one, the slow one simply carries on at its own pace. When a slow component depends on a fast one, every change in the fast one raises the question of whether the slow one still behaves correctly. The stable code has quietly inherited the churn.
The book gives this a name, effective volatility. In plain words, take a component's own rate of change, compare it with the rate of every dependency it has, and the larger figure is its effective volatility. A calm module that imports a restless one is, in practice, a restless module, and no amount of careful labelling changes that. This is arguably the most useful idea here, because it explains why one stray import can make a "stable" layer unstable.
The same rule also keeps the dependency graph free of loops. The book lists four reasons that matters:
Detection is a solved problem, and so are the standard fixes: pull the shared piece down into a lower layer, invert the dependency through an interface, or introduce a mediator. The book's view is that all of them are painful to apply to an old codebase under pressure, which is why it prefers to prevent loops by construction. A graph in which every edge points from fast to slow cannot contain one. For how to find loops that already exist, see detecting dependency cycles before they ship.
A principle that depends on goodwill will eventually lose to a deadline. Löwy's third rule, the project-to-project reference rule, moves enforcement out of people's heads and into the build. Each volatility level becomes its own compilation unit, whether that is a project, a package or a module depending on your ecosystem. The references between units are declared in the build files, and those declarations are the law.
rider-app depends on: fare-rules, ride-types
fare-rules depends on: ride-types
ride-types depends on: (nothing)
With a manifest like this, a developer who tries to call booking-screen code from inside the fare rules gets a compile error, not a code-review comment. The violation cannot be built, so no one has to argue about it. The book calls this arguably the most practically important part of the method, because it shifts architectural enforcement from the social layer (reviews, documents, conventions) to the mechanical one.
It also says something about how to read the other two rules. They describe what a good structure looks like. The third is what stops the structure decaying while you are busy with something else.
If you remember one thing, remember the cost of an upward import: it does not just break a rule, it transfers volatility to code that was supposed to be stable. Group by change rate, point dependencies towards stability, and make the compiler the guard. LVD keeps all three rules; the folder-as-layer principle is the physical form of rule three, and why LVD cannot contain cycles shows what rule two guarantees.