ANATOMIE EINER
HEXAGONALEN
ARCHITEKTUR
Lightweight Java User Group München
20. März 2023
OTTO
Solutions Architect @ Comsysto Reply
SVEN
Solutions Architect @ Comsysto Reply
A little bit of history …
Hexagonal
Architecture
2005
Alistair Cockburn
“Ports & Adapters Architecture”
- Separation of Concerns
- (UI & DB) Testability & Mockability
- “Primary/Secondary” or
“Driving/Driven” Adapters
- Use Cases as Application Boundary
https://alistair.cockburn.us/hexagonal-architecture/
Onion
Architecture
2008
Jeffrey Palermo
- Separation of Concerns via Controlled Coupling
- Application Core: Object Model
(Domain Model) with Business Rules
- Externalize Infrastructure
- Relies on Dependency Inversion
https://jeffreypalermo.com/2008/07/the-onion-architecture-part-1/
Clean
Architecture
2012
Robert C. Martin
- The Dependency Rule
- Entities encapsulate Business Rules
- Use Cases as Layer
- What and how to cross boundaries: Flow
- Different wording, similar concepts
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
Enter the
Microservice Hype
2012+
- Microservices
- Domain-Driven Design (DDD)
- CQRS
- …
-
We need to talk!
DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together
Let’s start with the
essentials …
There is one
essential thing …
… there is the inside and the outside …
Alistair Cockburn
Dennis Hamilton - https://www.flickr.com/photos/orcmid/1850093537/
There is one
essential thing …
.. and it needs to be connected …
Why should I care?
Separate
Technologies
Does this look familiar?
Does this look familiar?
Separate
Technologies
Separate
Representations
Have it your way …
Okay, what do I have to
do?
A Layered
Architecture …
… and a Hexagonal
Architecture …
It’s a Question of
Ownership
In a layered architecture …
It’s a Question of
Ownership
In a hexagonal architecture …
It’s a Question of
Dependency
It’s a Question of
Dependency
What's inside the
Hexagon?
Inside the Inner
Hexagon …
The most
important parts …
There is another
thing …
… but it is often not so important to
differentiate …
Things to note about
ports …
Incoming vs.
Outgoing Ports
… the same goes for adapters …
Incoming Ports
… are often use case centric …
Outgoing Ports
… are often domain object centric …
What is my domain?
What is my domain
anyway?
https://github.com/ddd-crew/core-domain-charts
Distilled to …
- Think domain first
- Use the domain objects in the ports
if possible
- Isolate technologies in the adapters
- Move business logic as far to the
center as possible
It’s not so
complicated
- Better testability
- Easier to understand
- Easier to adapt to technological
changes
- Easier to guard against regressions
- Easier to focus on business code
And the benefits
are …
DANKE
FÜR EURE
AUFMERKSAMKEIT!
https://www.comsystoreply.com
@comsysto
www.comsysto.tv
ljug-meetup-2023-03-hexagonal-architecture.pdf

ljug-meetup-2023-03-hexagonal-architecture.pdf