Agentic Development

Hexagonal architecture favored for testability over layered models

Hexagonal architecture is argued to be superior to traditional layered approaches because it prevents technical dependencies from leaking into business logic. This design inversion allows core logic to be tested independently of specific database or UI implementations.

· 1 source · Architecture patterns

In a discussion on the Heise Software Architektur Podcast, the speaker argued that hexagonal architecture, also known as Ports and Adapters or Clean Architecture, offers significant advantages over traditional three-layer architecture for business systems. The primary criticism of layered approaches is that the logic layer often depends on the persistence layer, leading to hidden technical dependencies. For example, business logic may catch specific database exceptions from Oracle or SAP, which complicates unit testing and creates arbitrary coupling. The speaker noted that while layered architectures offer information hiding, they often fail to provide true abstraction because data models in the logic layer are frequently inspired by the database schema, resulting in mismatches.

Hexagonal architecture resolves this by reversing the dependency direction. The core business logic defines ports, or interfaces, while adapters, such as database or UI implementations, depend on the core. This inversion ensures that the core logic remains independent of technical details. The speaker emphasized that the main advantage is testability, as adapters can be easily replaced with mocks or test drivers. This approach also clarifies the placement of third-party systems, treating them as adapters to specific ports rather than ambiguous components above or below the logic layer. The speaker referenced a previous episode with Tom Hombergs and Johannes Seitz on the same podcast, which discussed Clean Architecture in similar terms.