Five Ways to Decompose a System, and What Each Misses
Five classic ways to decompose a system, applied to one ride-sharing app: what each does well, where it falls short, and the question none of them answers.
Nobody sets out to build a system that is painful to change. Yet most engineers can name a codebase where a one-line tweak to a form meant edits in six places, the full build took long enough to go and get lunch, and the newest hire spent a quarter afraid to touch anything. That is rarely bad luck or bad people. It is what happens when a steady stream of change meets a structure that was never designed to absorb it.
Most of what we build is a model of something outside the computer: a bus timetable, a hospital ward, a stock exchange, a warehouse. The model is only useful while it matches reality, and reality keeps moving. This idea sits at the centre of Meir Lehman's laws of software evolution, formulated from the 1970s onwards and collected with Laszlo Belady in a 1985 volume. A program that is used in a real environment has to be continually adapted, or it becomes steadily less useful. A second law adds the uncomfortable part: as a program is changed, its complexity grows unless somebody does deliberate work to reduce it.
The book makes the same point in its opening pages. Evolution is not evidence that the original design failed. It is a property of software itself. The useful question is therefore not "how do we stop change?" but "how do we structure code so that change stays local?"
To see how much change is coming, picture a ticketing service for a regional bus company, built with a ten-year horizon. The book sorts the pressures on a long-lived system into five families, and each one shows up in this service:
None of these is exotic. Over ten years, every one of them will happen at least once, and each carries the risk of breaking something that was working.
Poor decomposition is not an abstract sin. The book lists five concrete symptoms, and each is something you can observe without any special tooling.
Ripple effects. You change one feature and find yourself editing files that seem unrelated. The symptom to track is how many files a typical change touches, and how many of those you did not expect. When the number keeps climbing, boundaries are leaking.
Build dependencies. Circular dependencies make modular builds impossible. If module A needs B and B needs A, a build tool cannot compile one without the other, so a small edit triggers a full rebuild. Build times stretch from minutes toward hours, and slow feedback quietly wrecks developer momentum.
Testing challenges. Tightly coupled code is hard to test in isolation, so teams lean on slow, flaky integration tests. Tests that need a database, a message queue and three neighbouring modules to start up get run less often, and eventually people stop trusting them.
Onboarding friction. Where components lack clear boundaries, a newcomer cannot tell where one responsibility ends and another begins. The honest answer to "where does this logic live?" becomes "ask Priya, she was there when it was written." That is knowledge held in people's heads instead of in the structure.
Technical debt. Fred Brooks observed in The Mythical Man-Month that repairs to a system tend to erode its structure, so that each fix leaves behind a little more disorder. Debt compounds like interest. Each shortcut makes the next change slightly more expensive, which tempts the next shortcut.
These five reinforce one another. Slow builds discourage testing, weak tests make people afraid of change, and fear produces the defensive, copy-and-paste edits that deepen the coupling.
Early in a project, none of this hurts. With a dozen files, everyone knows where everything is, and a cross-cutting change is an afternoon of work. The trouble is that the number of possible connections grows much faster than the number of components. Ten modules can be wired together in forty-five different pairs; a hundred modules allow nearly five thousand. Unless something actively limits which pairs are permitted, a growing codebase drifts toward the dense end of that range.
That is why rot is easy to underestimate. The cost of a change is roughly the number of things it can disturb, and what it can disturb is everything that depends on the changed code, directly or through a chain of other components. A team that was fast in year one and sluggish in year four has not become less talented. Its graph has become denser, and every change now has far more ways to go wrong.
It also explains why heroic clean-up efforts so often disappoint. Rewriting a module without changing the rules about who may depend on whom restores the structure for a few months. The same pressures then push it back toward the same shape.
Abstract talk of coupling hides how ordinary it looks. Here is a perfectly plausible pair of modules from the ticketing service:
// bookings.ts
import { applyPromotion } from "./promotions";
export const isPeakTravel = (b: Booking) => b.departure.getHours() >= 16;
export const priceBooking = (b: Booking) =>
applyPromotion(b, b.baseFare);
// promotions.ts
import { isPeakTravel } from "./bookings"; // the loop closes here
export const applyPromotion = (b: Booking, fare: number) =>
isPeakTravel(b) ? fare : fare * 0.9;
Nobody wrote this to be clever. A developer needed the peak-time check, saw it next door, and imported it. Now neither module can be loaded, tested or reasoned about alone. Changing the peak window affects promotions, changing promotion rules means opening bookings, and any attempt to move one into its own package drags the other along.
Multiply that by a few hundred modules and ten years of deadlines, and you have the codebase from the opening paragraph. No single decision looked reckless. The structure rotted through a long series of locally reasonable choices.
The book frames the cost of poor decomposition through two cautionary cases, and the contrast between them is the most useful part. The first is a very large monolith with no module boundaries: tangled dependencies, changes that touch a wide spread of packages, releases so risky that they happen rarely. Everyone recognises that picture.
The second is the opposite reaction. An e-commerce startup, wanting to escape the monolith, splits itself into dozens of services without any guiding principles. Responsibilities overlap and ownership is unclear. Services call long chains of other services, several teams keep their own divergent schemas for the same concept, simple requests need distributed tracing to debug, and shipping one feature means coordinating many deployments.
The lesson is easy to miss. Splitting a system is not the same as decomposing it. A network boundary does not remove coupling; it makes coupling slower, harder to see and more expensive to debug. The microservice sprawl failed for the same underlying reason as the monolith, which is that nobody had a principled answer to "where should the lines go?"
Putting boundaries in the wrong place is often worse than having none, because wrong boundaries make every change cross them.
This leads to the chapter's central claim. Every system gets divided into parts. The only choice is whether the division is made deliberately, through architectural design, or accidentally, through a thousand ad-hoc decisions made under deadline pressure. Declining to decide is itself a decision, and usually a poor one.
Once you accept that, the question shifts from "should we decompose?" to "what criteria should guide the cuts?" Teams have answered this in different ways over the decades: by feature, by object, by business domain, by technical tier, by reusable component. The next articles in this series look at how those answers developed, in sixty years of architecture, and at what each one misses, in five decomposition strategies compared.
In the meantime you can audit your own system without reading anything else. Take the five symptoms and ask a pointed question of each:
If the answers make you wince, the problem is not effort. The structure is working against you.
Software rots because it is a living model in a changing world, and structure that ignores how the world changes turns every change into a ripple. The five symptoms, from sprawling edits to rising debt, are measurable, which means decomposition is something you can evaluate rather than argue about. What remains is the choice of criterion for where the lines go, and the book's answer, developed in the chapters that follow, is the rate of change itself.