Why Software Rots: The Hidden Cost of Poor Decomposition
Software rots when steady change meets a structure never built to absorb it. Five measurable symptoms, and why decomposition is the cure.
Software rots when steady change meets a structure never built to absorb it. Five measurable symptoms, and why decomposition is the cure.
A tour of software architecture from 1960s monoliths through tiers, SOA and microservices: what each era fixed, what it broke, and the questions still open.
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.
Volatility is how often a component is expected to change. Define it, measure it, and one dependency rule falls out: lean only on code steadier than you.
The five claims behind Layered Volatility Decomposition, how to read each one critically, how the book is organised, and a way to test them on your own code.
Juval Löwy's premise that modules exist to contain change, and why that leads to boundaries drawn by rate of change instead of by feature.
Volatility as the primary axis, dependencies that flow from fast to slow, and a build system that enforces it: the three rules behind VBD, in plain language.
The three tiers of volatility-based decomposition and the roles that live in them (accessors, engines, managers), with a short ride-hailing walk-through.
Two field stories of volatility-based decomposition, a bank's loan system and a factory, plus a git command to test the idea in your own repository.
Two everyday scenarios, a partner API and an AI assistant, show where a three-tier model has no place to put things, and when it still works fine.
The few graph-theory ideas an architect needs: directed graphs, cycles, DAGs, topological order and strongly connected components.
Why dependency cycles hurt builds, tests and comprehension, and how a depth-first search or Tarjan's algorithm finds them in linear time.
How the book turns volatility into a number, from commit counts to composite scores, and when a volatility-respecting order exists.
How a two-step graph check can verify an architecture automatically, what to do when it fails, and how volatility numbers can suggest layer boundaries.
A plain-English tour of LVD's nine layers, from Schema to UI: what each one holds, why it sits where it does, and the rule that connects them.
The case for finer layers: three tiers hide mixed volatility, and four modern pressures (microservices, AI, many protocols, compliance) make it worse.
LVD's core rule is a comparison of layer numbers. See how it works on a small example, why same-layer imports are the loophole, and why loops cannot form.
Make the layers visible in the file tree: why one top-level folder per layer helps navigation, tooling and migration, with a ticketing-service sketch.
Three-tier, hexagonal, Clean Architecture, DDD and LVD each sort code by a different question. Why that makes LVD a complement and not a rival.
The Schema layer is LVD's lowest and most stable layer. See what belongs in it, how to pick a schema language, and how to lay out its folders.
Per-field checks miss rules that span fields, and shared schemas can lose them between languages. Two fixes for a Schema layer used by several services.
The Utils layer holds pure functions grouped by business domain. See what purity buys you, why technical folders fail, and the complexity cap the book sets.
One small feature carried through the two bottom layers: a rental schema with a cross-field rule, and pure fare utilities that import its types.
Trace three kinds of change through a tool that uses Schema, Utils and Resources, and see why the two bottom layers earn the heaviest testing.
Repository, Adapter, Facade and Anti-Corruption Layer are four ways the Resources layer translates between outside systems and your domain model.
A retry loop can prolong an outage it was meant to ride out. Here is a capped, jittered backoff you can prove correct, and the layers LVD gives each part.
Caching and error translation both hide something from callers: where data came from and how a vendor fails. See how the Resources layer handles each.
Resources code talks to slow, stateful systems. Mocks, containers and contract tests each answer a different question about it, and 80% coverage is the target.
Where to put the vendor-neutral contract so that a hospital switching EHR systems becomes a contained change in the Resources layer.
Every LVD tool comes out of one factory with five named parts. Here is what they are, why validation stays out of the handler, and what a two-part result buys.
One tool per directory, names that read as commands, and a registry that discovers tools at startup: how LVD keeps Layer 4 easy to navigate as it grows.
Inside a tool, resource calls and pure functions combine in four ways: in sequence, in parallel, by condition, and with a plan for failure. How to choose.
Why the tool, not the repository, owns the transaction boundary, and when a workflow that spans services needs a saga with compensating steps instead.
Axiom A5 forbids tools from depending on other tools. Here is why that small rule keeps a business-logic layer testable, acyclic and easy to change.
How LVD tools are tested with injected resources, which four behaviours to pin down, where integration tests take over, and what the TradeX trading tools show.
The API layer has one job: protocol translation. What a thin REST route looks like, how domain errors become status codes, and how to pick a versioning style.
GraphQL and gRPC are extra adapters over the same tools, and OpenAPI docs can come straight from Schema-layer definitions. Where each concern belongs in LVD.
Why LVD puts authentication and authorization in a sublayer of the API layer, not in tools, and how JWT, OAuth, API keys, roles and rate limits fit together.
What the Model Context Protocol layer (L6) does in LVD: a standard adapter that lets AI agents find, understand and call tools without knowing your internals.
How to authenticate AI agents at an MCP server without a classic middleware bug, and how to report tool failures so a model can act on them.
REST routes and MCP tools are adapters, so their tests check contracts, not business rules. The kinds of test LVD uses, and what one end-to-end check proves.
Skills are the one LVD layer made of documents, not code. See what a skill file contains and why its error-handling section carries the most weight.
How LVD keeps skill documents honest: versioned beside the code, linked to tool schemas, validated in the build and tested through their example conversations.
In LVD an agent is an explicit configuration, not just a prompt. How its parts fit together and how it picks, sequences and recovers tool calls.
How LVD watches an AI agent in production and limits what it may do: metrics, anomaly alerts, confirmations, tool-level authorisation and human oversight.
Skills score 0.95 and Agents 0.97. Why the order matters, what drives change in each layer and how a change in the upper layers stays local.
The book's customer-service agent lists its limits in its own configuration. Here is why a limit that matters should also be enforced one layer down.
Why the second edition promotes the UI from outside client to Layer 9, and how a simple inheritance rule for volatility puts it above Agents.
One import rule keeps a front end changeable: features never import each other. Why it holds, and what to do when two features need the same thing.
How to decide whether a rule belongs in a component or behind the API, and why server data should be treated as a cache instead of copied into a store.
Two jobs belong at the seam between a screen and the API: assembling the data a screen needs, and turning failures into outcomes a user can act on.
A screen that shows an AI agent should depend on the agent's event contract rather than its prompts, and approvals must be enforced by the host, not the page.
Why accessibility is cheapest in the UI's shared components, and how tests that find elements by role and name double as an accessibility check.
The book's storefront example shows a button and a chat assistant reaching the same business rule. Why that shared path is the best test of a UI layer.
Architecture debates run on adjectives. Here is the book's ten-property yardstick for comparing LVD with other designs, and how to borrow it on your own code.
Clean Architecture and LVD both point dependencies at the stable core, but differ in how finely they slice the outer rings and in what they say about AI and UI.
Hexagonal architecture splits a system into inside and outside; LVD slices both halves by volatility. How the two map onto each other and where each is simpler.
LVD and domain-driven design are not rivals. One tells you what to model, the other where each piece lives. How the concepts map and how to combine them.
Three tiers promise downward dependencies but allow shortcuts. Why that mixes volatilities, how cycles creep in, and a five-phase path to LVD.
Microservices decide how a system is cut into deployable pieces; LVD decides how each piece is built inside. How they nest, and how to combine them.
How the book's ShopFlow example spreads a retail platform across nine layers, and how three teams split the work along those layers.
What a retail platform's change log reveals about its layers: some changes stay below, some add above, a few cut across. A tour of the book's ShopFlow events.
What the book's ShopFlow case study found easy, what it found hard, and what it would tell the next team, from layer-shaped defects to testing agents.
The book's MedConnect case study asks whether LVD's layers can double as compliance boundaries in a healthcare platform: the setting, the idea, the team.
A walk up the MedConnect stack: what the schema, utility, resource, tool, API and UI layers each contribute to protecting patient data, and why.
Two security ideas from the MedConnect case study: treat the purpose of a request as an input, and never let the browser vouch for itself.
How MedConnect traces every request through the layers, writes tamper-evident audit entries, logs who saw which fields and why, and keeps records for years.
Why the book projects lower compliance overhead for a layered healthcare platform, what still hurt (training, encryption, legacy systems) and what it advises.
How lvd-lint turns LVD's dependency rules into an automated check: cycle detection, layer violations and an alignment score, run from the command line or CI.
lvd-diagram draws layer diagrams from the real dependency graph, and its heatmap overlays git history to show where code changes more than its layer predicts.
lvd-metrics condenses architectural health into five numbers, with gates for CI and trend reports that warn you before a threshold is actually crossed.
Where LVD's checks belong in the delivery flow: pre-commit hook, pull-request pipeline with differential metrics comments, and editor feedback as you type.
LVD gives each layer its own rung on the test pyramid and its own coverage target. Here is the reasoning, and why layering makes testing easier.
How to test Schema, Utils, Resources and Tools in LVD: exhaustive rule checks, property-based tests, containers for adapters and mocks at the resource boundary.
API and UI code translate between worlds, so test the translation, not the business rules: contract tests, UI outcome tests and where end-to-end fits.
The plumbing behind LVD test suites: test data patterns, four ways to fake a dependency, and a parallel run order that follows the layer graph.
Tests that punish refactoring teach teams to stop refactoring. Two traps layered code invites: mocking inside a layer and snapshotting a volatile one.
Before moving any file, measure: extract the dependency graph, compute volatility from history, find the gaps against the target layers, and plan bottom-up.
A tour of the book's nine-step migration roadmap: extract the stable layers first, add the AI-facing layers last, and gate every step on checks you can run.
A long migration branch loses to a main branch that keeps moving. Two LVD migration patterns on a ticketing codebase: strangler signposts and temporary flags.
A monolith lacks boundaries; a microservice estate may have the wrong ones. How LVD migration differs for each.
How to staff and train a layered migration, answer resistance with data, and handle four recurring obstacles from cycles to stranded UI logic.
A utility function that quietly calls the database breaks Axiom A2. See how upward imports creep in, what they cost, and the small refactor that undoes them.
A shared enum pulled from a tool and a tool that calls another tool: two one-line imports that quietly break the dependency rules of LVD.
Every import points downward and the lint run is green, yet a layer is doing the wrong job. Three anti-patterns where purpose, not direction, is the problem.
Over-layering, under-layering and misplaced volatility are system-level mistakes. Here is how to recognise each and test it against evidence.
The UI is where shortcuts are most tempting. Three anti-patterns that break Axiom A6 or the UI's own ordering rules, and how each one is caught.
Why one upward import costs more than it looks, and why a gate should fail the build only on the few violations a machine can judge with certainty.
Small services still contain code that changes at different speeds. How LVD applies inside one microservice, and how to pick the layers it actually needs.
Shared types, service-to-service calls and sagas all have a home in LVD. The network boundary needs no new layer rules, only a clear path through Resources.
How an event travels between two LVD services, and why the consumer, where raw bytes become a typed event, is the place to be strict.
LVD organises code and microservices organise deployment. Why that makes topology a reversible choice, and what a service mesh still leaves to your code.
How Domain-Driven Design's tactical building blocks land on LVD's layers, and why rate of change, not habit or taste, settles each placement.
How to combine DDD bounded contexts with LVD layers: give each context its own full stack, and treat the shared kernel as a small Schema package.
Every layer imports Schema types, so Schema is where a team's shared vocabulary can be enforced. Enums are the first place to start.
How DDD aggregates shape the Tools layer: one root per set of tools, one aggregate per transaction, and sagas driven by domain events for anything wider.
Where domain events live in LVD: schemas in L1, emission from Tools, consumption through Resources, and event sourcing spread across four layers.
A whole bounded context laid out layer by layer, from schemas to protocol adapters, using a library lending example alongside the book's order management case.
A practical test for when LVD alone is enough and when Domain-Driven Design belongs beside it, with a way to introduce DDD gradually instead of all at once.
The book proposes measuring volatility from version control instead of opinion. Here is why that beats memory, and three ways the record can still fool you.
Two research directions from the book's closing chapter: language models that review layer assignments, and systems that adapt their structure at runtime.
The book's last chapter proposes mappings and open questions, not results. Three are worth pulling on: smart contracts, the layer count and cognitive load.
A plain-language proof sketch of why a strict one-way layer ordering rules out dependency cycles, and where the guarantee needs an extra rule.
The whole idea of Layered Volatility Decomposition in one sitting: sort code by how often it changes, depend only downward, and let nine layers do the rest.
A one-page reference to LVD's nine layers: volatility coefficients, what lives in each, what does not, plus the dependency rule and axioms A5 and A6.
What changed in the second edition of LVD, why the UI earned its own layer, and how a team used to the eight-layer picture can adopt the change.
Where tools, MCP servers, skills, agents and the UI sit in LVD, why each is placed there, and how that keeps prompt tuning from rippling through your system.