SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Hexagonal Architecture
Nicolas Guignard
Allow an application to equally be driven by users, programs,
automated test, and to be developed and tested in isolation from
its eventual run-time devices and databases.
Intent
● Clean Architecture
● Ports/Adapters
● Left wing side/right side
● Domain-driven design
● Evolutive architecture / VIPER…
Other similar
architectures/buzzwords?
HEXAGONAL ARCHITECTURE
How does the kitchen of a chef look like?
Why do we need it?
How does the kitchen of a chef look like?
Why do we need it?
Image from Shutterstock here
Software is a living creature that needs to
Why do we need a good architecture?
Be maintainable
Evolve
Do several similar and very different things
Be flexible
Be testable Self explanatory
● Put the software at the service of the business.
● Technology is a detail, business is what matters.
● Can your PO read your tests or your code and understands what it does ?
● Push for independence of the business area from the technology infrastructure
● Make it easy to evolve
● Allow re-usability
What is the goal of the Hexagonal
Architecture?
How is the Hexagonal Architecture
working?
● Separate the Domain - Business from the rest
How is the Hexagonal Architecture
working?
How is the Hexagonal Architecture
working?
● Technical layers have dependencies with the domain, outside-in
How is the Hexagonal Architecture
working?
This looks like some Circle Architecture no ?
Not reallyyyyyyyy
How is the Hexagonal Architecture
working?
How is the Hexagonal Architecture
working?
How is the Hexagonal Architecture
working?
● Users / Application:
○ What is provided to the end user of our domain
○ They need us
● Providers / Infrastructure:
○ What we depend on
How is the Hex-Archi working for instance
for us?
How is the Hex-Archi working for instance
for us?
At compile time:
At compile time:
Class diagram
How is the Hex-Archi working for instance
for us?
At runtime:
public class Program {
public static void Main(String[] args)
{
// 1. Instantiate right-side adapter ("Infrastructure most likely in our case")
// What we depend on
SomeOtherPort infraAdapter = new SomeKindOfAdapter("argument");
// 2. Instantiate the Domain
// Our business logic
ISomePort domain = new LogicThanImplementSomePort(infraAdapter);
// 3. Instantiate the application side
// What our users depend on
SomeRestController controller = new SomeRestController(domain);
}
}
Details
● Ports:
○ Interfaces
○ Contract to respect for adapter
● Adapters:
○ Implement interfaces
○ Are interchangeables
○ Are throwable
○ Are mockable
● Example:
○ Replace PostgreSQL by Oracle → no impact on the domain
○ Replace RabbitMQ by Kafka →
Details
● Domain:
○ Should use domain language only
○ Should be easy to unit test
○ Could have easily implemented behaviour driven test
○ Could be Domain-driven designed
○ MUST not have any dependency on other parts of the application
○ Lean on Dependency Injection and pass only interfaces
Details
● Testing Strategy:
○ Mock / stub / fake your infrastructure adapters
○ Test the whole domain independently of infrastructure or application
○ Can test: Application → Domain
○ Can test: Domain → Infrastructure
○ MUST STILL test infrastructure and application parts
A good architect defers decisions
Quote?
BUT ...
● Beware:
○ Your database model isn’t your domain model.
○ You don’t start designing your db to build your domain model
● Challenge yourself:
○ Can your PO/PM write the BDD test for you and read your code and understand it? If yes:
congrats, your architecture should be quite neat and be able to evolve.
○ Embrace changes, to do so you will have to improve your code base and architecture
○ Self discipline
TIPS ...
● Multi module projects with right dependencies
● Define your domain language to align everybody
● Ask yourself:
○ Is your code easily testable ?
○ Does it use heavily mocks ? → could be a bad smell
○ Are your decisions reversible? They should be
● The less modules/packages and your code is coupled the better you’ll be
● You want to use different technologies for Application/domain/infra → DO IT, you can, don‘t
base your architecture on the language you use
Does it scale?
Yes but what if ?
Annexe and content we took ideas from
● https://fr.slideshare.net/nicolascarlo1/hexagonal-architecture-elixir
● https://fr.slideshare.net/ThomasPierrain/coder-sans-peur-du-changement-avec-la-meme-pas-mal-hexagonal-architecture
● https://blog.octo.com/en/hexagonal-architecture-three-principles-and-an-implementation-example/
● https://fr.slideshare.net/nicolascarlo1/the-secrets-of-hexagonal-architecture
Thank You
www.online-pajak.com
QUESTIONS ?

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
 
Kata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and AdaptersKata: Hexagonal Architecture / Ports and Adapters
Kata: Hexagonal Architecture / Ports and Adapters
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software Craftsmanship
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob 2012 the clean architecture by Uncle bob
2012 the clean architecture by Uncle bob
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design(DDD) Presentation
Domain Driven Design(DDD) PresentationDomain Driven Design(DDD) Presentation
Domain Driven Design(DDD) Presentation
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 

Semelhante a Hexagonal architecture

Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplus
Mark Veltzer
 

Semelhante a Hexagonal architecture (20)

Develop, deploy, and operate services at reddit scale oscon 2018
Develop, deploy, and operate services at reddit scale   oscon 2018Develop, deploy, and operate services at reddit scale   oscon 2018
Develop, deploy, and operate services at reddit scale oscon 2018
 
LAS16-108: JerryScript and other scripting languages for IoT
LAS16-108: JerryScript and other scripting languages for IoTLAS16-108: JerryScript and other scripting languages for IoT
LAS16-108: JerryScript and other scripting languages for IoT
 
Introduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OKIntroduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OK
 
Software Architecture - All you need to know
Software Architecture - All you need to knowSoftware Architecture - All you need to know
Software Architecture - All you need to know
 
Meetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCMeetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaC
 
Evolving to Cloud-Native - Anand Rao
Evolving to Cloud-Native - Anand RaoEvolving to Cloud-Native - Anand Rao
Evolving to Cloud-Native - Anand Rao
 
From class to architecture
From class to architectureFrom class to architecture
From class to architecture
 
On component interface
On component interfaceOn component interface
On component interface
 
Javascript Programming according to Industry Standards.pptx
Javascript Programming according to Industry Standards.pptxJavascript Programming according to Industry Standards.pptx
Javascript Programming according to Industry Standards.pptx
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Data Science in Production: Technologies That Drive Adoption of Data Science ...
Data Science in Production: Technologies That Drive Adoption of Data Science ...Data Science in Production: Technologies That Drive Adoption of Data Science ...
Data Science in Production: Technologies That Drive Adoption of Data Science ...
 
From prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.ioFrom prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.io
 
AirBNB's ML platform - BigHead
AirBNB's ML platform - BigHeadAirBNB's ML platform - BigHead
AirBNB's ML platform - BigHead
 
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
 Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa... Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
Bighead: Airbnb’s End-to-End Machine Learning Platform with Krishna Puttaswa...
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservices
 
Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplus
 
APIDays SF 2019: Managing multiple api stacks on serverless
APIDays SF 2019: Managing multiple api stacks on serverlessAPIDays SF 2019: Managing multiple api stacks on serverless
APIDays SF 2019: Managing multiple api stacks on serverless
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From Production
 
SACON NY 19: "Creating an effective developer experience for cloud-native apps"
SACON NY 19: "Creating an effective developer experience for cloud-native apps"SACON NY 19: "Creating an effective developer experience for cloud-native apps"
SACON NY 19: "Creating an effective developer experience for cloud-native apps"
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Último (20)

WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 

Hexagonal architecture

  • 2. Allow an application to equally be driven by users, programs, automated test, and to be developed and tested in isolation from its eventual run-time devices and databases. Intent
  • 3. ● Clean Architecture ● Ports/Adapters ● Left wing side/right side ● Domain-driven design ● Evolutive architecture / VIPER… Other similar architectures/buzzwords? HEXAGONAL ARCHITECTURE
  • 4. How does the kitchen of a chef look like? Why do we need it?
  • 5. How does the kitchen of a chef look like? Why do we need it? Image from Shutterstock here
  • 6. Software is a living creature that needs to Why do we need a good architecture? Be maintainable Evolve Do several similar and very different things Be flexible Be testable Self explanatory
  • 7. ● Put the software at the service of the business. ● Technology is a detail, business is what matters. ● Can your PO read your tests or your code and understands what it does ? ● Push for independence of the business area from the technology infrastructure ● Make it easy to evolve ● Allow re-usability What is the goal of the Hexagonal Architecture?
  • 8. How is the Hexagonal Architecture working? ● Separate the Domain - Business from the rest
  • 9. How is the Hexagonal Architecture working?
  • 10. How is the Hexagonal Architecture working? ● Technical layers have dependencies with the domain, outside-in
  • 11. How is the Hexagonal Architecture working? This looks like some Circle Architecture no ? Not reallyyyyyyyy
  • 12. How is the Hexagonal Architecture working?
  • 13. How is the Hexagonal Architecture working?
  • 14. How is the Hexagonal Architecture working? ● Users / Application: ○ What is provided to the end user of our domain ○ They need us ● Providers / Infrastructure: ○ What we depend on
  • 15. How is the Hex-Archi working for instance for us?
  • 16. How is the Hex-Archi working for instance for us? At compile time:
  • 18. How is the Hex-Archi working for instance for us? At runtime: public class Program { public static void Main(String[] args) { // 1. Instantiate right-side adapter ("Infrastructure most likely in our case") // What we depend on SomeOtherPort infraAdapter = new SomeKindOfAdapter("argument"); // 2. Instantiate the Domain // Our business logic ISomePort domain = new LogicThanImplementSomePort(infraAdapter); // 3. Instantiate the application side // What our users depend on SomeRestController controller = new SomeRestController(domain); } }
  • 19. Details ● Ports: ○ Interfaces ○ Contract to respect for adapter ● Adapters: ○ Implement interfaces ○ Are interchangeables ○ Are throwable ○ Are mockable ● Example: ○ Replace PostgreSQL by Oracle → no impact on the domain ○ Replace RabbitMQ by Kafka →
  • 20. Details ● Domain: ○ Should use domain language only ○ Should be easy to unit test ○ Could have easily implemented behaviour driven test ○ Could be Domain-driven designed ○ MUST not have any dependency on other parts of the application ○ Lean on Dependency Injection and pass only interfaces
  • 21. Details ● Testing Strategy: ○ Mock / stub / fake your infrastructure adapters ○ Test the whole domain independently of infrastructure or application ○ Can test: Application → Domain ○ Can test: Domain → Infrastructure ○ MUST STILL test infrastructure and application parts
  • 22. A good architect defers decisions Quote?
  • 23. BUT ... ● Beware: ○ Your database model isn’t your domain model. ○ You don’t start designing your db to build your domain model ● Challenge yourself: ○ Can your PO/PM write the BDD test for you and read your code and understand it? If yes: congrats, your architecture should be quite neat and be able to evolve. ○ Embrace changes, to do so you will have to improve your code base and architecture ○ Self discipline
  • 24. TIPS ... ● Multi module projects with right dependencies ● Define your domain language to align everybody ● Ask yourself: ○ Is your code easily testable ? ○ Does it use heavily mocks ? → could be a bad smell ○ Are your decisions reversible? They should be ● The less modules/packages and your code is coupled the better you’ll be ● You want to use different technologies for Application/domain/infra → DO IT, you can, don‘t base your architecture on the language you use
  • 25. Does it scale? Yes but what if ?
  • 26. Annexe and content we took ideas from ● https://fr.slideshare.net/nicolascarlo1/hexagonal-architecture-elixir ● https://fr.slideshare.net/ThomasPierrain/coder-sans-peur-du-changement-avec-la-meme-pas-mal-hexagonal-architecture ● https://blog.octo.com/en/hexagonal-architecture-three-principles-and-an-implementation-example/ ● https://fr.slideshare.net/nicolascarlo1/the-secrets-of-hexagonal-architecture