SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
Hexagonal Architecture: Why Architecture
Hexagonal architecture is a specific instance of an architecture
pattern. Why do we need one at all?
Make software easier to change
Make software easier to test
Make software easier to reason about
Make software easier to write with fewer bugs
Reduce the future cost of changing your mind later, about
nearly anything
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Definition
What is Hexagonal Architecture?
An alternative to the “standard layered model”
Developed by Alistair Cockburn
Later called Ports and Adapters
Also called the Onion Architecture
Involves application of the Dependency Inversion Principle
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Contrast
What is the Standard Layered Model?
UI
Application
Domain
Network and database
Hexagonal architecture rejects the notion that any of these layers
except the domain are different from one another. E.g. a user
sitting at a UI is not much different than a flat file full of test
cases, or a network and a database.
Michael Nash Hexagonal Architecture
Layered Architecture: Diagram
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Diagram
Domain on the inside, infrastructure (ports and adapters) on the
outside
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Value
Why Hexagonal Architecture?
What does this architecture buy us?
Symmetrical
Verifiable – you can tell when you’ve got it by inspection
Decouple core logic (the domain) from infrastructure
Always possible to test everything easily
Infrastructure changes are not relevant to the domain logic
Makes package and module structure consistent and easy to
navigate
Natural fit with DDD and EDA
Language and framework agnostic
Excellent fit with functional programming
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Ports and Adapters
Infrastructure services can easily be replaced with others
Michael Nash Hexagonal Architecture
Dependency Inversion Principle
To apply Hexagonal architecture, we use the dependency inversion
principle
Specific top-level package structure
Careful management of imports and dependency management
Common classes depend on nothing (no IO, utilities only)
Domain classes depend only on common classes and each
other
Services classes depend on domain, adapt to infrastructure
Infrastructure classes depend on services and domain
Michael Nash Hexagonal Architecture
Dependency Inversion Principle: Diagram
Michael Nash Hexagonal Architecture
Dependency Inversion Principle: Common
The Common package contains only shared utility classes
No I/O!
String utilities
Date utilities
Random numbers
Data structures
NOT what we currently call “common”
Michael Nash Hexagonal Architecture
Dependency Inversion Principle: Domain
The Domain package contains only business domain classes and
functions
Depends ONLY on other domain classes and common classes
Can use abstractions like logging (traits only)
Contains domain logic – avoid anemic domain!
No I/O
Can contain DDD services for operations that span aggregates
No DTOs
No annotations
Use types, not primitives wherever possible
Michael Nash Hexagonal Architecture
Dependency Inversion Principle: Services
The Services package contains the service classes used by the ports
and adapters to interact with the domain
Depends ONLY on domain and common
Expose operations needed by the adapters
No I/O
Could contain Repositories
No event handlers (these are infrastructure)
No REST routing (again, infrastructure)
No DTOs
No annotations
Michael Nash Hexagonal Architecture
Dependency Inversion Principle: Infrastructure
The Infrastructure package contains the adapters that connect the
services and the domain to the outside world
Can depend on any other package as required
Contains sub-packages for specific adapters (e.g. http,
eventbus, mongo)
I/O goes here – all of it
Calls services and domain
REST routing goes here
Implementations of repositories go here
DTOs go here
Guice module, dependency injection goes here
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Action Plan
How do we get there? What’s the plan?
Review Hierarchy (now), make sure we all understand the
desired outcome
In other modules, create top-level packages domain, common,
services and infrastructure
Refactor into proper package structure, decoupling as required
Decouple from deprecated common modules
Refactor spray-service-common and submodules into re-usable
infrastructure modules
Use Crucible to review and discuss refactors
Specific stories to refactor each module
Decouple EventBus from our domain (make domain-agnostic)
Adopt single-source tree view to facilitate refactorings
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Single Sourcetree View
A single bounded context should be visible as a single logical
source tree
No more p2build plugin
Refactoring greatly simplified
No more versions of common
Executable artifacts become a deploy-time question: can
change as needed
Acheivable “virtually” right away with git sub-modules
(ListingDistributionContext)
Adding new Event types (for example) becomes trivial
One git repo (logically, if not physically at first)
Decouple EventBus from our domain (make domain-agnostic)
Integration tests become trivial (no need to launch multiple
jars)
Michael Nash Hexagonal Architecture
Hexagonal Architecture: Conclusion
We want the benefits of hexagonal architecture, hence the
refactors
Questions?
Michael Nash Hexagonal Architecture

Mais conteúdo relacionado

Mais procurados

Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)Matthias Noback
 
The Quest for Global Design Principles
The Quest for Global Design PrinciplesThe Quest for Global Design Principles
The Quest for Global Design PrinciplesMatthias Noback
 
Arquitectura hexagonal
Arquitectura hexagonalArquitectura hexagonal
Arquitectura hexagonal540deg
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016Matthias Noback
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in phpLeonardo Proietti
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCDomain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCSteven Smith
 
Distributed Computing
Distributed ComputingDistributed Computing
Distributed Computingadil raja
 
Hexagonal architecture for the web
Hexagonal architecture for the webHexagonal architecture for the web
Hexagonal architecture for the webJesús Espejo
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Enea Gabriel
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NETRiccardo Terrell
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHPSteve Rhoades
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Onion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureOnion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureAttila Bertók
 
The framework as an implementation detail
The framework as an implementation detailThe framework as an implementation detail
The framework as an implementation detailMarcello Duarte
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLCAbdul Karim
 
Application architecture
Application architectureApplication architecture
Application architectureIván Stepaniuk
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureThomas Jaskula
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)IT Arena
 

Mais procurados (20)

Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
 
The Quest for Global Design Principles
The Quest for Global Design PrinciplesThe Quest for Global Design Principles
The Quest for Global Design Principles
 
Arquitectura hexagonal
Arquitectura hexagonalArquitectura hexagonal
Arquitectura hexagonal
 
Hexagonal architecture in PHP
Hexagonal architecture in PHPHexagonal architecture in PHP
Hexagonal architecture in PHP
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016
 
Clean architecture with ddd layering in php
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCDomain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVC
 
Distributed Computing
Distributed ComputingDistributed Computing
Distributed Computing
 
Hexagonal architecture for the web
Hexagonal architecture for the webHexagonal architecture for the web
Hexagonal architecture for the web
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
Onion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureOnion Architecture / Clean Architecture
Onion Architecture / Clean Architecture
 
The framework as an implementation detail
The framework as an implementation detailThe framework as an implementation detail
The framework as an implementation detail
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Application architecture
Application architectureApplication architecture
Application architecture
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)
 

Semelhante a Hexagonal

[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology
[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology
[WSO2Con USA 2018] Deep-dive into Agile Architecture and MethodologyWSO2
 
Webinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessWebinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessOpenXcell Technolabs
 
SodiusCassidianmdday2010 101129081449-phpapp02
SodiusCassidianmdday2010 101129081449-phpapp02SodiusCassidianmdday2010 101129081449-phpapp02
SodiusCassidianmdday2010 101129081449-phpapp02SodiusWillert
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"LogeekNightUkraine
 
Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandtmfrancis
 
How to Think Multi-Cloud
How to Think Multi-CloudHow to Think Multi-Cloud
How to Think Multi-CloudRightScale
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arpGary Pedretti
 
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...Productionizing Predictive Analytics using the Rendezvous Architecture - for ...
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...danielschulz2005
 
Full lifecycle of a microservice
Full lifecycle of a microserviceFull lifecycle of a microservice
Full lifecycle of a microserviceLuigi Bennardis
 
Oo Design And Patterns
Oo Design And PatternsOo Design And Patterns
Oo Design And PatternsAnil Bapat
 
17 applied architectures
17 applied architectures17 applied architectures
17 applied architecturesMajong DevJfu
 
Advanced application architecture
Advanced application architectureAdvanced application architecture
Advanced application architectureMatthias Noback
 
Advanced Application Architecture (workshop slides)
Advanced Application Architecture (workshop slides)Advanced Application Architecture (workshop slides)
Advanced Application Architecture (workshop slides)Matthias Noback
 
An agile approach to cloud infrastructure
An agile approach to cloud infrastructureAn agile approach to cloud infrastructure
An agile approach to cloud infrastructureRichard Seroter
 
Sodius cassidian mdday2010
Sodius cassidian mdday2010Sodius cassidian mdday2010
Sodius cassidian mdday2010MD DAY
 

Semelhante a Hexagonal (20)

Onion (clean) architecture
Onion (clean) architectureOnion (clean) architecture
Onion (clean) architecture
 
[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology
[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology
[WSO2Con USA 2018] Deep-dive into Agile Architecture and Methodology
 
Webinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to ServerlessWebinar - Mobile Apps: Monolithic to Serverless
Webinar - Mobile Apps: Monolithic to Serverless
 
SodiusCassidianmdday2010 101129081449-phpapp02
SodiusCassidianmdday2010 101129081449-phpapp02SodiusCassidianmdday2010 101129081449-phpapp02
SodiusCassidianmdday2010 101129081449-phpapp02
 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
 
Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandt
 
How to Think Multi-Cloud
How to Think Multi-CloudHow to Think Multi-Cloud
How to Think Multi-Cloud
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...Productionizing Predictive Analytics using the Rendezvous Architecture - for ...
Productionizing Predictive Analytics using the Rendezvous Architecture - for ...
 
HCE project brief
HCE project briefHCE project brief
HCE project brief
 
Full lifecycle of a microservice
Full lifecycle of a microserviceFull lifecycle of a microservice
Full lifecycle of a microservice
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Oo Design And Patterns
Oo Design And PatternsOo Design And Patterns
Oo Design And Patterns
 
17 applied architectures
17 applied architectures17 applied architectures
17 applied architectures
 
Sca
ScaSca
Sca
 
L02 Architecture
L02 ArchitectureL02 Architecture
L02 Architecture
 
Advanced application architecture
Advanced application architectureAdvanced application architecture
Advanced application architecture
 
Advanced Application Architecture (workshop slides)
Advanced Application Architecture (workshop slides)Advanced Application Architecture (workshop slides)
Advanced Application Architecture (workshop slides)
 
An agile approach to cloud infrastructure
An agile approach to cloud infrastructureAn agile approach to cloud infrastructure
An agile approach to cloud infrastructure
 
Sodius cassidian mdday2010
Sodius cassidian mdday2010Sodius cassidian mdday2010
Sodius cassidian mdday2010
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Hexagonal

  • 1. Hexagonal Architecture: Why Architecture Hexagonal architecture is a specific instance of an architecture pattern. Why do we need one at all? Make software easier to change Make software easier to test Make software easier to reason about Make software easier to write with fewer bugs Reduce the future cost of changing your mind later, about nearly anything Michael Nash Hexagonal Architecture
  • 2. Hexagonal Architecture: Definition What is Hexagonal Architecture? An alternative to the “standard layered model” Developed by Alistair Cockburn Later called Ports and Adapters Also called the Onion Architecture Involves application of the Dependency Inversion Principle Michael Nash Hexagonal Architecture
  • 3. Hexagonal Architecture: Contrast What is the Standard Layered Model? UI Application Domain Network and database Hexagonal architecture rejects the notion that any of these layers except the domain are different from one another. E.g. a user sitting at a UI is not much different than a flat file full of test cases, or a network and a database. Michael Nash Hexagonal Architecture
  • 4. Layered Architecture: Diagram Michael Nash Hexagonal Architecture
  • 5. Hexagonal Architecture: Diagram Domain on the inside, infrastructure (ports and adapters) on the outside Michael Nash Hexagonal Architecture
  • 6. Hexagonal Architecture: Value Why Hexagonal Architecture? What does this architecture buy us? Symmetrical Verifiable – you can tell when you’ve got it by inspection Decouple core logic (the domain) from infrastructure Always possible to test everything easily Infrastructure changes are not relevant to the domain logic Makes package and module structure consistent and easy to navigate Natural fit with DDD and EDA Language and framework agnostic Excellent fit with functional programming Michael Nash Hexagonal Architecture
  • 7. Hexagonal Architecture: Ports and Adapters Infrastructure services can easily be replaced with others Michael Nash Hexagonal Architecture
  • 8. Dependency Inversion Principle To apply Hexagonal architecture, we use the dependency inversion principle Specific top-level package structure Careful management of imports and dependency management Common classes depend on nothing (no IO, utilities only) Domain classes depend only on common classes and each other Services classes depend on domain, adapt to infrastructure Infrastructure classes depend on services and domain Michael Nash Hexagonal Architecture
  • 9. Dependency Inversion Principle: Diagram Michael Nash Hexagonal Architecture
  • 10. Dependency Inversion Principle: Common The Common package contains only shared utility classes No I/O! String utilities Date utilities Random numbers Data structures NOT what we currently call “common” Michael Nash Hexagonal Architecture
  • 11. Dependency Inversion Principle: Domain The Domain package contains only business domain classes and functions Depends ONLY on other domain classes and common classes Can use abstractions like logging (traits only) Contains domain logic – avoid anemic domain! No I/O Can contain DDD services for operations that span aggregates No DTOs No annotations Use types, not primitives wherever possible Michael Nash Hexagonal Architecture
  • 12. Dependency Inversion Principle: Services The Services package contains the service classes used by the ports and adapters to interact with the domain Depends ONLY on domain and common Expose operations needed by the adapters No I/O Could contain Repositories No event handlers (these are infrastructure) No REST routing (again, infrastructure) No DTOs No annotations Michael Nash Hexagonal Architecture
  • 13. Dependency Inversion Principle: Infrastructure The Infrastructure package contains the adapters that connect the services and the domain to the outside world Can depend on any other package as required Contains sub-packages for specific adapters (e.g. http, eventbus, mongo) I/O goes here – all of it Calls services and domain REST routing goes here Implementations of repositories go here DTOs go here Guice module, dependency injection goes here Michael Nash Hexagonal Architecture
  • 14. Hexagonal Architecture: Action Plan How do we get there? What’s the plan? Review Hierarchy (now), make sure we all understand the desired outcome In other modules, create top-level packages domain, common, services and infrastructure Refactor into proper package structure, decoupling as required Decouple from deprecated common modules Refactor spray-service-common and submodules into re-usable infrastructure modules Use Crucible to review and discuss refactors Specific stories to refactor each module Decouple EventBus from our domain (make domain-agnostic) Adopt single-source tree view to facilitate refactorings Michael Nash Hexagonal Architecture
  • 15. Hexagonal Architecture: Single Sourcetree View A single bounded context should be visible as a single logical source tree No more p2build plugin Refactoring greatly simplified No more versions of common Executable artifacts become a deploy-time question: can change as needed Acheivable “virtually” right away with git sub-modules (ListingDistributionContext) Adding new Event types (for example) becomes trivial One git repo (logically, if not physically at first) Decouple EventBus from our domain (make domain-agnostic) Integration tests become trivial (no need to launch multiple jars) Michael Nash Hexagonal Architecture
  • 16. Hexagonal Architecture: Conclusion We want the benefits of hexagonal architecture, hence the refactors Questions? Michael Nash Hexagonal Architecture