Assessing a Codebase Before You Migrate
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 flawless migration plan fails if the people who have to carry it out are confused, overloaded or unconvinced. The book spends as much time on the human side as on the technical side, and then lists the obstacles that tend to appear on almost every project. Here are the ones most worth knowing before you start.
Two team shapes work in practice. Layer-focused teams give each layer, or group of layers, to a dedicated group, such as a foundation team for Schema and Utils, an integration team for Resources and a logic team for Tools and API. That builds depth of expertise and consistent design. Cross-functional teams instead take a vertical slice, such as payments, and restructure it through every layer. That preserves domain knowledge and cuts hand-offs.
The book's recommendation depends on size. Below ten engineers, use cross-functional teams organised by domain. Above that, use a hybrid: a small foundation team of two or three engineers builds Schema, Utils and Resources, while cross-functional teams handle the domain-specific tools and everything above. The foundation team is meant to finish within the first eight weeks and then disperse to strengthen the others, so the specialists end up spread through the organisation rather than becoming a bottleneck.
For preparation, it asks that everyone understand the layer model, the tooling, the migration patterns and, importantly, what "done" means for each step. A half-day workshop and a short hands-on lab with lvd-lint and the metrics tool are enough, and two or three migration champions who have finished a pilot extraction can coach the rest.
Resistance is expected, so the book prepares answers built on data rather than enthusiasm. "We have no time" is met with the Change Impact Radius: if a typical feature already drags a long list of files along with it, the team is paying a tax on every change. "The current code works" is conceded, with the reply that the goal is cheaper future change. "It is just rearranging deckchairs" is met with measured before-and-after results. "We will lose velocity" is partly true, and the honest answer is the J-curve: output dips for several weeks, then recovers and passes the old level.
The book calls circular dependencies the single most common blocker to extracting a layer, and offers three techniques. Take a ride-sharing example in which a pricing module imports a trip type from the dispatch module, while dispatch imports a surge calculation from pricing.
The first technique fits the example best: the trip type is the shared fact, and Schema is where shared facts belong.
Schema evolution comes up because extracting schemas reveals that one entity is represented differently in different places. The book's strategy is a canonical schema with adapter functions in Utils that convert each legacy shape, removed once all consumers have moved. For schemas exposed through an API, it adds versioning, with explicit conversion functions between versions.
Performance regression is the cumulative effect of extra calls and indirections. The safeguards are to record latency percentiles before you begin, benchmark after every step, set a budget of no more than five per cent regression per percentile, and use canary deployments for evidence from real traffic. If a step goes over budget, the usual cure is removing an unnecessary adapter or inlining a hot path.
The fourth obstacle is new in the second edition: business logic stranded in UI components. Lifting a rule out of a component seldom preserves behaviour exactly, since the server may lack that rule or implement a slightly different version. The recommended route is to pin down what the component computes with tests, implement the rule below in Utils and expose it through a tool and the API, then run the old and new values side by side for a while, logging any difference, and delete the client-side calculation only when the logs go quiet.
Migrations succeed when the plan has people in it: teams shaped to the size of the effort, objections answered with numbers, and a known playbook for the four obstacles that keep returning. For the rest of the plan, see the nine-step roadmap and the patterns that keep a system running; for the cycle theory behind the first obstacle, why LVD cannot contain dependency cycles.