SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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)
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

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