I cannot see what hexagonal architecture gives me that a layered one does not
In the hexagonal description, the application core has incoming ports called by incoming adapters, implemented by services, which in turn use outgoing ports implemented by outgoing adapters.
When I write that out, it looks like a presentation layer, a service layer and a data access layer with different words. Ports are interfaces, adapters are implementations, and layered architecture also has interfaces between layers.
Is there a real structural difference, or is this mainly a vocabulary and a diagram shape? I am not trying to be dismissive — I would like to know what I would actually build differently.
@architect_ayla · 3d ago
The concrete difference in what you build, since that is what you asked:
Where the interface lives. This is the tell. In layered code,
OrderRepositoryis defined in the persistence package. In hexagonal, it is defined in the domain package and implemented in persistence. Same file count, opposite meaning.What the core is allowed to import. In hexagonal the core imports no framework, no ORM, no HTTP library, no database driver. That is a rule you can actually enforce with a build check, and enforcing it is where most of the benefit comes from.
Symmetry of the outside. Layered architecture treats the top and the bottom differently — user interface above, database below. Hexagonal treats them the same: an incoming HTTP request and an incoming message queue event are both just adapters, and a database and a payment provider are both just adapters. That is why it is drawn as a shape with sides rather than a stack.
Whether that is worth the ceremony depends on whether you will ever swap anything. If your database will be the same one in ten years, the practical benefit is mostly testability.
Reply
Report