Q13 · What are the trade-offs between layered, vertical slice, and hexagonal architectures?

Back to 24 Architecture Questions.

The question is not “which is modern”. The axis it turns on: where a change lands, and how much unrelated code it drags with it. All three organize the same code; they differ in what a feature change touches, and what a technology change touches.

Where a change lands In a layered architecture a feature change walks through UI, business logic, and data layers. In a vertical slice it lands in one slice. In a hexagonal architecture a business change lands in the domain core without touching the ports. FIGURE 13 WHERE A CHANGE LANDS Layered UI Business Logic the rules Data the change walks every layer Vertical Slice Orders ui · logic · data no layer crossing the change lands in one slice Hexagonal HTTP port Domain Core the business DB port the change lands in the core

What the answer should contain

Layered: changes walk the stack. UI, business, data: one feature touches all three, plus the seams between them. The strength is a simple mental model and obvious reuse; the cost is that every feature is smeared across the codebase, and layers organized by kind (all the controllers here, all the repositories there) tempt the business rules to leak into the wrong layer.

Vertical slice: changes land in one place. A feature is one slice, UI to data. Adding a feature adds a slice; deleting one deletes a slice. The cost is duplication across slices and the constant temptation to grow a “common” module that quietly becomes a new layer everyone depends on. Discipline: a thin shared kernel, deliberately starved.

Hexagonal: the domain never learns the technology. The core holds the business rules and exposes ports; adapters translate HTTP, databases, and message brokers into them. Swapping an adapter touches the core not at all, and the core is testable without infrastructure. The cost is ceremony: for a CRUD app with two rules, ports and adapters buy indirection with nothing to protect.

Pick by change profile, and say which changes you expect. Features churn fastest: slices win. The delivery technology churns (framework migration, DB swap, adding a message bus): hexagonal wins. Small team, simple CRUD: layered is honest and cheap. And they compose: hexagonal inside a vertical slice is a common, sound combo.

The test is the drag metric. For the last ten features: how many files did each touch, and how many of those were about something else? That number, trended, tells you more than any diagram.

Ideas worth mentioning out loud

Follow-ups to expect

Red flags in an answer

Sources