SlideShare a Scribd company logo
Hexagonal architecture: how, why and when
Hexagonal
architecture: how,
why and when
Hexagonal Architecture: how, why and when - 11/2019 3
About meAbout me
Carlos Gándara
software developer at
@xoubaman
Hexagonal Architecture: how, why and when - 11/2019 4
Why?
Hexagonal Architecture: how, why and when - 11/2019 5
A journey through
architectural patterns
Hexagonal Architecture: how, why and when - 11/2019 6
Hexagonal Architecture: how, why and when - 11/2019 7
Spaghetti
Hexagonal Architecture: how, why and when - 11/2019 8
Spaghetti architecture
✅ Fun to revisit after some years...
✅ Valid for small proof of concept scripts
with a 10 minutes life expectancy
...although that means you have it on production
Hexagonal Architecture: how, why and when - 11/2019 9
Hexagonal Architecture: how, why and when - 11/2019 10
MVC
Hexagonal Architecture: how, why and when - 11/2019 11
HTTP
language
Database
language
Business
rules
Data
centric
MVC architecture
Hexagonal Architecture: how, why and when - 11/2019 12
Ctrl+C
Ctrl+V
We want to add
products from the
console
MVC architecture
Hexagonal Architecture: how, why and when - 11/2019 13
I just realized
products have also
a max price
WET code
(makes you sweat)
MVC architecture
Hexagonal Architecture: how, why and when - 11/2019 14
Controllers go fat
MVC architecture
Hexagonal Architecture: how, why and when - 11/2019 15
MVC architecture
❌ No isolation of business logic
✅ Valid for prototyping and purely CRUD applications
❌ Data centric
❌ Hard to test, infrastructure everywhere
Hexagonal Architecture: how, why and when - 11/2019 16
Hexagonal Architecture: how, why and when - 11/2019 17
Layered architecture
Hexagonal Architecture: how, why and when - 11/2019 18
Layered architecture
HTTP & CLI
Same application
service
Diagram from book DDD in PHP
Hexagonal Architecture: how, why and when - 11/2019 19
Layered architecture (the wrong way)
Now need to read
products from this
random API
And we should
notify warehouse
guys
Database
language
Outside
world
Outside
world
Our thing
Hexagonal Architecture: how, why and when - 11/2019 20
Layered architecture (the wrong way)
Hey, plz generate a
RSS feed with
products we read
from this weird
machine
And did I
mentioned we
are migrating to
Mongo?
Combinatorial explosion
Infrastructure coupling
Hexagonal Architecture: how, why and when - 11/2019 21
Layered architecture (the wrong way)
Hey, plz generate a
RSS feed with
products we read
from this weird
machine
And did I
mentioned we
are migrating to
Mongo?
Combinatorial explosion
Infrastructure coupling
Aren’t tests
taking too much
time?
Testability
Hexagonal Architecture: how, why and when - 11/2019 22
Layered architecture
❌ Data persistence is in the core*
✅ Separation of concerns
✅ Application layer encapsulating use cases
❌ Potential infrastructure leaks in other layers*
✅ You can build good stuff
❌ Lasagna antipattern
* if you do it wrong
Hexagonal Architecture: how, why and when - 11/2019 23
Hexagonal Architecture: how, why and when - 11/2019 24
Hexagonal architecture
Hexagonal Architecture: how, why and when - 11/2019 25
Aka Ports and Adapters
Coined by Alistair Cockburn in 2005
Hexagonal architecture
Check out Alistair in the "Hexagone" in Youtube
Hexagonal Architecture: how, why and when - 11/2019 26
Allow an application to equally be driven by users,
programs, automated test or batch scripts, and to be
developed and tested in isolation from its eventual run-time
devices and databases.
Hexagonal architecture
Hexagonal Architecture: how, why and when - 11/2019 27
Outside the application
A boundary
Application
Hexagonal architecture
Hexagonal Architecture: how, why and when - 11/2019 28
Port:
● Outside element
communicating with the
application
● Defined by an interface*
Application
Adapter:
● Implementation of a port
interface into what
application understands
*Not a code interface, although
sometimes represented by one
Ports and adapters
Hexagonal Architecture: how, why and when - 11/2019 29
Primary ports
Drivers
Secondary ports
Repositories and
recipients
Ports and adapters
Hexagonal Architecture: how, why and when - 11/2019 30
Test driver
User interface
Router + HTTP Controller
Ports and adapters
CLI
Console component
REST API
External application
Other adapter
Other adapter
Hexagonal Architecture: how, why and when - 11/2019 31
Ports and adapters
REST API adapter with Symfony:
● Routing component
● HTTP Kernel and Controller
● HTTP component Request
Hexagonal Architecture: how, why and when - 11/2019 32
Ports and adapters
Persistence
Queue
Feed
Interface implementation
Interface implementation
Interfaces
defined by the
application
Hexagonal Architecture: how, why and when - 11/2019 33
Ports and adapters
Persistence adapter with Doctrine ORM
Application defines the contract in its
own language
We don’t care about using database
or library language in the adapter
Hexagonal Architecture: how, why and when - 11/2019 34
Ports and adapters
Persistence adapter with Doctrine ORM
No infrastructure leaks
Testability improved!
Hexagonal Architecture: how, why and when - 11/2019 35
How?
Hexagonal Architecture: how, why and when - 11/2019 36
Allow an application to equally be driven by users,
programs, automated test or batch scripts, and to be
developed and tested in isolation from its eventual run-time
devices and databases.
Hexagonal architecture
No mention to
layers...
Hexagonal Architecture: how, why and when - 11/2019 37
Hexagonal architecture
You can put whatever you want inside the hexagon
Hexagonal Architecture: how, why and when - 11/2019 38
Hexagonal + Layered
Hexagonal Architecture: how, why and when - 11/2019 39
Hexagonal + Layered
Hexagonal Architecture: how, why and when - 11/2019 40
User Interface and Infrastructure layer:
● UI for primary ports adapters
● Infrastructure for secondary ports implementations
Application layer:
● Defines the system use cases
● Orchestrates the domain logic
● Command + Command Handler pattern
Domain layer:
● Holds all the business logic and invariants
● Defines the contracts implemented in infrastructure
Hexagonal + Layered: a proposal
Hexagonal Architecture: how, why and when - 11/2019 41
Hexagonal + Layered
Domain
Application
UI
Infrastructure
Hexagonal Architecture: how, why and when - 11/2019 42
Hexagonal + Layered: Domain layer
Domain
Application
UI
Infrastructure
Don’t leak
infrastructure in
your domain
Hexagonal Architecture: how, why and when - 11/2019 43
Hexagonal + Layered: Application layer
Domain
Application
UI
Infrastructure
More logic
than this is
suspicious
Hexagonal Architecture: how, why and when - 11/2019 44
Hexagonal + Layered: Driver port
Domain
Application
UI
Infrastructure
Hexagonal Architecture: how, why and when - 11/2019 45
Hexagonal + Layered: Repository port
Domain
Application
UI
Infrastructure
Dependency inversion
Hexagonal Architecture: how, why and when - 11/2019 46
When?
Hexagonal Architecture: how, why and when - 11/2019 47
When to apply hexagonal architecture?
ALWAYS*
Hexagonal Architecture: how, why and when - 11/2019 48
When to apply hexagonal architecture?
Pros
● Testability
● Promotes separation of
concerns
● Pushes accidental complexity
out of the domain
● Open/Closed
● Handy base for DDD
● Handy base for CQRS and ES
Cons
● Indirection
● Amount of boilerplate code
Hexagonal Architecture: how, why and when - 11/2019 49
When to apply hexagonal architecture?
Makes no sense for
● Scripting
● Prototyping
● Tooling
● Frameworks
Makes sense for
● Applications relying on external technologies
● CRUD applications
● Anything more complex than that
Hexagonal Architecture: how, why and when - 11/2019 50
When to apply hexagonal architecture?
Take decisions based on the context and needs
Keep in mind the reasons and the consequences
ALWAYS
Hexagonal Architecture: how, why and when - 11/2019 51
Questions?
Hexagonal Architecture: how, why and when - 11/2019
● Slides of this presentation anytime soon in @xoubaman
● Article: Hexagonal Architecture by Alistair Cockburn
● Article: Hexagonal Architecture by Fideloper
● Article: DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together by Hebert Graca
● Video: Introducción Arquitectura Hexagonal (Spanish) by CodelyTV
● Video: Hexagonal Architecture - Message-Oriented Software Design by Matthias Noback
● Video: Alistair in the “Hexagone” by DDD FR
● Book: DDD in PHP by Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary
● Book: Implementing Domain Driven Design by Vaughn Vernon
● Code samples glittered with Carbon
52
Some resources to follow up
Thank you!
Ad

More Related Content

What's hot (20)

The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal Architecture
Nicolas Carlo
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
Fabricio Epaminondas
 
Hexagonal architecture
Hexagonal architectureHexagonal architecture
Hexagonal architecture
Nicolas Guignard
 
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Carlos Buenosvinos
 
Kata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and AdaptersKata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and Adapters
holsky
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
Matthias Noback
 
Hexagonal architecture in PHP
Hexagonal architecture in PHPHexagonal architecture in PHP
Hexagonal architecture in PHP
Paulo Victor Gomes
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
Badoo
 
AWS CDK Introduction
AWS CDK IntroductionAWS CDK Introduction
AWS CDK Introduction
Kasun Dilunika
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
Mattia Battiston
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Chris Richardson
 
Microservice
MicroserviceMicroservice
Microservice
Viney Shih
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Hannah Farrugia
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Ryan Riley
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
Fabrício Rissetto
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
Kashif Ali Siddiqui
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean Architecture
Roc Boronat
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
The Software House
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
wojtek_s
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal Architecture
Nicolas Carlo
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
Fabricio Epaminondas
 
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Hexagonal Architecture - PHP Barcelona Monthly Talk (DDD)
Carlos Buenosvinos
 
Kata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and AdaptersKata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and Adapters
holsky
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
Matthias Noback
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Steve Pember
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
Badoo
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
Mattia Battiston
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Chris Richardson
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Ryan Riley
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
Fabrício Rissetto
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
Kashif Ali Siddiqui
 
Introducing Clean Architecture
Introducing Clean ArchitectureIntroducing Clean Architecture
Introducing Clean Architecture
Roc Boronat
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
The Software House
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
wojtek_s
 

Similar to Hexagonal architecture: how, why and when (20)

UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
Karen Cannell
 
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, AirbusAPIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
apidays
 
Why Splunk Chose Pulsar_Karthik Ramasamy
Why Splunk Chose Pulsar_Karthik RamasamyWhy Splunk Chose Pulsar_Karthik Ramasamy
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
Pulsar summit-keynote-final
Pulsar summit-keynote-finalPulsar summit-keynote-final
Pulsar summit-keynote-final
Karthik Ramasamy
 
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in..."Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
DECIDEH2020
 
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
Yenlo
 
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Trivadis
 
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
APEX Interactive Grid API Essentials:  The Stuff You Will Really UseAPEX Interactive Grid API Essentials:  The Stuff You Will Really Use
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
Karen Cannell
 
2019 09-13 kubernetes is hard - k8s community days
2019 09-13 kubernetes is hard - k8s community days2019 09-13 kubernetes is hard - k8s community days
2019 09-13 kubernetes is hard - k8s community days
Eldad Assis
 
Web Development
Web DevelopmentWeb Development
Web Development
Shubham Khan
 
Agile Mëtteg series session 7
Agile Mëtteg series session 7Agile Mëtteg series session 7
Agile Mëtteg series session 7
Agile Partner S.A.
 
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approachDevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps_Fest
 
Apache Pulsar @Splunk
Apache Pulsar @SplunkApache Pulsar @Splunk
Apache Pulsar @Splunk
Karthik Ramasamy
 
Bring cloud on premises with a kubernetes-native infrastructure
Bring cloud on premises with a kubernetes-native infrastructureBring cloud on premises with a kubernetes-native infrastructure
Bring cloud on premises with a kubernetes-native infrastructure
Abhinav Joshi
 
Serverless Kafka Patterns
Serverless Kafka PatternsServerless Kafka Patterns
Serverless Kafka Patterns
Taras Slipets
 
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry DaysStock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Vidyasagar Machupalli
 
Openbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar 2 - Leuven - Faros - Invisible InfrastructureOpenbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar
 
Cloud native past, present and future
Cloud native past, present and futureCloud native past, present and future
Cloud native past, present and future
Cheryl Hung
 
Empowering your Process Automation with Machine Learning
Empowering your Process Automation with Machine LearningEmpowering your Process Automation with Machine Learning
Empowering your Process Automation with Machine Learning
Lykle Thijssen
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
VMware Tanzu
 
UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
UTOUG Training Days 2019 APEX Interactive Grids: API Essentials, the Stuff Yo...
Karen Cannell
 
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, AirbusAPIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
APIdays Paris 2019 - Challenges at Global Scale by Nizar Chaouch, Airbus
apidays
 
Why Splunk Chose Pulsar_Karthik Ramasamy
Why Splunk Chose Pulsar_Karthik RamasamyWhy Splunk Chose Pulsar_Karthik Ramasamy
Why Splunk Chose Pulsar_Karthik Ramasamy
StreamNative
 
Pulsar summit-keynote-final
Pulsar summit-keynote-finalPulsar summit-keynote-final
Pulsar summit-keynote-final
Karthik Ramasamy
 
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in..."Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
"Contribution to the uptake of Cloud Computing solutions" by Juncal Alonso in...
DECIDEH2020
 
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
WSO2-Yenlo Integration Summit Stuttgart 15 may 2019
Yenlo
 
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Trivadis
 
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
APEX Interactive Grid API Essentials:  The Stuff You Will Really UseAPEX Interactive Grid API Essentials:  The Stuff You Will Really Use
APEX Interactive Grid API Essentials: The Stuff You Will Really Use
Karen Cannell
 
2019 09-13 kubernetes is hard - k8s community days
2019 09-13 kubernetes is hard - k8s community days2019 09-13 kubernetes is hard - k8s community days
2019 09-13 kubernetes is hard - k8s community days
Eldad Assis
 
Agile Mëtteg series session 7
Agile Mëtteg series session 7Agile Mëtteg series session 7
Agile Mëtteg series session 7
Agile Partner S.A.
 
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approachDevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps Fest 2019. Володимир Кімак. Mobile CI/CD. Cross-platform app approach
DevOps_Fest
 
Bring cloud on premises with a kubernetes-native infrastructure
Bring cloud on premises with a kubernetes-native infrastructureBring cloud on premises with a kubernetes-native infrastructure
Bring cloud on premises with a kubernetes-native infrastructure
Abhinav Joshi
 
Serverless Kafka Patterns
Serverless Kafka PatternsServerless Kafka Patterns
Serverless Kafka Patterns
Taras Slipets
 
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry DaysStock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Stock portfolio analysis with Cloud Foundry and AI services - Cloud Foundry Days
Vidyasagar Machupalli
 
Openbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar 2 - Leuven - Faros - Invisible InfrastructureOpenbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar 2 - Leuven - Faros - Invisible Infrastructure
Openbar
 
Cloud native past, present and future
Cloud native past, present and futureCloud native past, present and future
Cloud native past, present and future
Cheryl Hung
 
Empowering your Process Automation with Machine Learning
Empowering your Process Automation with Machine LearningEmpowering your Process Automation with Machine Learning
Empowering your Process Automation with Machine Learning
Lykle Thijssen
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
VMware Tanzu
 
Ad

Recently uploaded (20)

NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025Top 12 Most Useful AngularJS Development Tools to Use in 2025
Top 12 Most Useful AngularJS Development Tools to Use in 2025
GrapesTech Solutions
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Why Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card ProvidersWhy Tapitag Ranks Among the Best Digital Business Card Providers
Why Tapitag Ranks Among the Best Digital Business Card Providers
Tapitag
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??Serato DJ Pro Crack Latest Version 2025??
Serato DJ Pro Crack Latest Version 2025??
Web Designer
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Ad

Hexagonal architecture: how, why and when

  • 3. Hexagonal Architecture: how, why and when - 11/2019 3 About meAbout me Carlos Gándara software developer at @xoubaman
  • 4. Hexagonal Architecture: how, why and when - 11/2019 4 Why?
  • 5. Hexagonal Architecture: how, why and when - 11/2019 5 A journey through architectural patterns
  • 6. Hexagonal Architecture: how, why and when - 11/2019 6
  • 7. Hexagonal Architecture: how, why and when - 11/2019 7 Spaghetti
  • 8. Hexagonal Architecture: how, why and when - 11/2019 8 Spaghetti architecture ✅ Fun to revisit after some years... ✅ Valid for small proof of concept scripts with a 10 minutes life expectancy ...although that means you have it on production
  • 9. Hexagonal Architecture: how, why and when - 11/2019 9
  • 10. Hexagonal Architecture: how, why and when - 11/2019 10 MVC
  • 11. Hexagonal Architecture: how, why and when - 11/2019 11 HTTP language Database language Business rules Data centric MVC architecture
  • 12. Hexagonal Architecture: how, why and when - 11/2019 12 Ctrl+C Ctrl+V We want to add products from the console MVC architecture
  • 13. Hexagonal Architecture: how, why and when - 11/2019 13 I just realized products have also a max price WET code (makes you sweat) MVC architecture
  • 14. Hexagonal Architecture: how, why and when - 11/2019 14 Controllers go fat MVC architecture
  • 15. Hexagonal Architecture: how, why and when - 11/2019 15 MVC architecture ❌ No isolation of business logic ✅ Valid for prototyping and purely CRUD applications ❌ Data centric ❌ Hard to test, infrastructure everywhere
  • 16. Hexagonal Architecture: how, why and when - 11/2019 16
  • 17. Hexagonal Architecture: how, why and when - 11/2019 17 Layered architecture
  • 18. Hexagonal Architecture: how, why and when - 11/2019 18 Layered architecture HTTP & CLI Same application service Diagram from book DDD in PHP
  • 19. Hexagonal Architecture: how, why and when - 11/2019 19 Layered architecture (the wrong way) Now need to read products from this random API And we should notify warehouse guys Database language Outside world Outside world Our thing
  • 20. Hexagonal Architecture: how, why and when - 11/2019 20 Layered architecture (the wrong way) Hey, plz generate a RSS feed with products we read from this weird machine And did I mentioned we are migrating to Mongo? Combinatorial explosion Infrastructure coupling
  • 21. Hexagonal Architecture: how, why and when - 11/2019 21 Layered architecture (the wrong way) Hey, plz generate a RSS feed with products we read from this weird machine And did I mentioned we are migrating to Mongo? Combinatorial explosion Infrastructure coupling Aren’t tests taking too much time? Testability
  • 22. Hexagonal Architecture: how, why and when - 11/2019 22 Layered architecture ❌ Data persistence is in the core* ✅ Separation of concerns ✅ Application layer encapsulating use cases ❌ Potential infrastructure leaks in other layers* ✅ You can build good stuff ❌ Lasagna antipattern * if you do it wrong
  • 23. Hexagonal Architecture: how, why and when - 11/2019 23
  • 24. Hexagonal Architecture: how, why and when - 11/2019 24 Hexagonal architecture
  • 25. Hexagonal Architecture: how, why and when - 11/2019 25 Aka Ports and Adapters Coined by Alistair Cockburn in 2005 Hexagonal architecture Check out Alistair in the "Hexagone" in Youtube
  • 26. Hexagonal Architecture: how, why and when - 11/2019 26 Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases. Hexagonal architecture
  • 27. Hexagonal Architecture: how, why and when - 11/2019 27 Outside the application A boundary Application Hexagonal architecture
  • 28. Hexagonal Architecture: how, why and when - 11/2019 28 Port: ● Outside element communicating with the application ● Defined by an interface* Application Adapter: ● Implementation of a port interface into what application understands *Not a code interface, although sometimes represented by one Ports and adapters
  • 29. Hexagonal Architecture: how, why and when - 11/2019 29 Primary ports Drivers Secondary ports Repositories and recipients Ports and adapters
  • 30. Hexagonal Architecture: how, why and when - 11/2019 30 Test driver User interface Router + HTTP Controller Ports and adapters CLI Console component REST API External application Other adapter Other adapter
  • 31. Hexagonal Architecture: how, why and when - 11/2019 31 Ports and adapters REST API adapter with Symfony: ● Routing component ● HTTP Kernel and Controller ● HTTP component Request
  • 32. Hexagonal Architecture: how, why and when - 11/2019 32 Ports and adapters Persistence Queue Feed Interface implementation Interface implementation Interfaces defined by the application
  • 33. Hexagonal Architecture: how, why and when - 11/2019 33 Ports and adapters Persistence adapter with Doctrine ORM Application defines the contract in its own language We don’t care about using database or library language in the adapter
  • 34. Hexagonal Architecture: how, why and when - 11/2019 34 Ports and adapters Persistence adapter with Doctrine ORM No infrastructure leaks Testability improved!
  • 35. Hexagonal Architecture: how, why and when - 11/2019 35 How?
  • 36. Hexagonal Architecture: how, why and when - 11/2019 36 Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases. Hexagonal architecture No mention to layers...
  • 37. Hexagonal Architecture: how, why and when - 11/2019 37 Hexagonal architecture You can put whatever you want inside the hexagon
  • 38. Hexagonal Architecture: how, why and when - 11/2019 38 Hexagonal + Layered
  • 39. Hexagonal Architecture: how, why and when - 11/2019 39 Hexagonal + Layered
  • 40. Hexagonal Architecture: how, why and when - 11/2019 40 User Interface and Infrastructure layer: ● UI for primary ports adapters ● Infrastructure for secondary ports implementations Application layer: ● Defines the system use cases ● Orchestrates the domain logic ● Command + Command Handler pattern Domain layer: ● Holds all the business logic and invariants ● Defines the contracts implemented in infrastructure Hexagonal + Layered: a proposal
  • 41. Hexagonal Architecture: how, why and when - 11/2019 41 Hexagonal + Layered Domain Application UI Infrastructure
  • 42. Hexagonal Architecture: how, why and when - 11/2019 42 Hexagonal + Layered: Domain layer Domain Application UI Infrastructure Don’t leak infrastructure in your domain
  • 43. Hexagonal Architecture: how, why and when - 11/2019 43 Hexagonal + Layered: Application layer Domain Application UI Infrastructure More logic than this is suspicious
  • 44. Hexagonal Architecture: how, why and when - 11/2019 44 Hexagonal + Layered: Driver port Domain Application UI Infrastructure
  • 45. Hexagonal Architecture: how, why and when - 11/2019 45 Hexagonal + Layered: Repository port Domain Application UI Infrastructure Dependency inversion
  • 46. Hexagonal Architecture: how, why and when - 11/2019 46 When?
  • 47. Hexagonal Architecture: how, why and when - 11/2019 47 When to apply hexagonal architecture? ALWAYS*
  • 48. Hexagonal Architecture: how, why and when - 11/2019 48 When to apply hexagonal architecture? Pros ● Testability ● Promotes separation of concerns ● Pushes accidental complexity out of the domain ● Open/Closed ● Handy base for DDD ● Handy base for CQRS and ES Cons ● Indirection ● Amount of boilerplate code
  • 49. Hexagonal Architecture: how, why and when - 11/2019 49 When to apply hexagonal architecture? Makes no sense for ● Scripting ● Prototyping ● Tooling ● Frameworks Makes sense for ● Applications relying on external technologies ● CRUD applications ● Anything more complex than that
  • 50. Hexagonal Architecture: how, why and when - 11/2019 50 When to apply hexagonal architecture? Take decisions based on the context and needs Keep in mind the reasons and the consequences ALWAYS
  • 51. Hexagonal Architecture: how, why and when - 11/2019 51 Questions?
  • 52. Hexagonal Architecture: how, why and when - 11/2019 ● Slides of this presentation anytime soon in @xoubaman ● Article: Hexagonal Architecture by Alistair Cockburn ● Article: Hexagonal Architecture by Fideloper ● Article: DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together by Hebert Graca ● Video: Introducción Arquitectura Hexagonal (Spanish) by CodelyTV ● Video: Hexagonal Architecture - Message-Oriented Software Design by Matthias Noback ● Video: Alistair in the “Hexagone” by DDD FR ● Book: DDD in PHP by Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary ● Book: Implementing Domain Driven Design by Vaughn Vernon ● Code samples glittered with Carbon 52 Some resources to follow up
  翻译: