SlideShare uma empresa Scribd logo
1 de 29
Domain Driven Design
&
Hexagonal Architecture
Handling Complex Business Logic
Can Pekdemir
About me
Expert Software Engineer @iyzico
Dokuz Eylul University – Computer Science – 2010
Worked as consultancy in various domains like finance, e-commerce, telecom
Speaking at meetups rarely
The term
Domain Driven Design:
Tackling Complexity in the Heart of Software,
Eric Evans, 2003
Our Biggest Problems
Growing Complexity
Time to Market
General problems in sw development
Thinking software development as a cost center rather than a profit center
Heavy usage of the latest sexy framework all cool kids talk about
Poor collaboration with the business
Not giving real emphasis to naming things
Wrong abstractions and generalizing solutions unnecessarily by thinking
about 5 years later
Domain Driven Design
An approach for solving complex business problems
A mindset of developing business not only software
Helps team organization, enterprise architecture, code design
Cope with technology challenges ( e.g. Enterprise frameworks, NoSql,
Microservices)
Big ball of mud
Exploring the domain with
collaboration
Hands-on Modelers
People who write the code should feel responsible for the model.
A modeler should not be separated from implementation.
Ubiquitous Language
One team, one language
No need for translation
Use in both communication and in the code
Bounded Context
A semantic contextual boundary
Divide large system into autonomous contexts
Be explicit about the context responsibilities
Set boundaries and relationships with each other
Care about team organization, code bases, database schemas
Make sense of Bounded Contexts for
your company
Strategic Design with Bounded Context
Started as a monolithic application
More teams operated on the same application
Ownership began to blur
Shared resources were making it difficult to scale-out
“the traditional model is that you take your software to the wall that
separates development and operations, and throw it over and then forget
about it. Not at Amazon. You build it, you run it.”
Werner Vogels, CTO, Amazon, 2006
http://queue.acm.org/detail.cfm?id=1142065
Real Numbers
Over 6000 employees
In 400 cities and 70 countries
From 200 engineers to 2000 Engineers only in a year and half
8000 git repositories
Over 1000 microservices
https://www.youtube.com/watch?v=kb-m2fasdDY
What I Wish I Had Known Before Scaling Uber to 1000 Services - Matt
Ranney
“Scaling the traffic is not the issue. Scaling the team and the product feature
release rate is the primary driver.”
Context Mapping
• Strategic domain driven design
• Very useful tool to understand overall architecture and relationships of the
system.
Relations of Bounded Contexts
Anti Corruption Layers
Protect your own domain from the dependent contexts
Translate unrelated namings into your own domain
Protect yourself from others’ failures with timeouts and circuit breakers
Integrate Bounded Contexts with
Restful API
See your API from the consumer’s eyes
Do not reflect your entities to restful resources directly
Use consumer driven contract libraries ( e.g. PACT, Spring Cloud Contracts )
Integrate Bounded Contexts with
Messaging
Design your domain events regarding your business logic
Use at-least-once delivery messaging mechanism
Be careful about your receivers to idempotent
Aggregates
Compose entities and value objects and mark one entity as root
Apply consistency boundaries within aggregates
Modify and commit only one aggregate instance in one transaction
Hint for microservices
Aggregates (2)
Aggregate Design Rules
Do not let your business logic inside an aggregate leak
Design small aggregates
Reference by identity only
Update other aggregates by eventual consistency ( optional for scalability )
Domain Events
A record of some business-significant occurence in bounded context
Append-only event store mechanisms can be implemented
Organize your Code
Baklava Code
Code with too many layers
Hexagonal Architecture
Technology free Domain Model
“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.” Alistair Cockburn – 2005
Decide on what is inside and outside
Benefits
Abstracts your business code from technical frameworks
Helps you to change your architectural decisions easily
Helps doing BDD and TDD
Packaging
Styles
Code time
References
Books
- Domain Driven Design: Tackling Complexity in the Heart of Software
- Domain Driven Design Distilled
- Implementing Domain Driven Design
- Building Microservices
Links
- http://www.codingthearchitecture.com/2016/04/25/layers_hexagons_features_and_components.html
- http://alistair.cockburn.us/Hexagonal+architecture
- https://www.johndcook.com/blog/2009/07/27/baklav-code/

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Scalable web architecture
Scalable web architectureScalable web architecture
Scalable web architecture
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Microservices with event source and CQRS
Microservices with event source and CQRSMicroservices with event source and CQRS
Microservices with event source and CQRS
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design Patterns
 
Event-driven microservices
Event-driven microservicesEvent-driven microservices
Event-driven microservices
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
Event Driven Microservices architecture
Event Driven Microservices architectureEvent Driven Microservices architecture
Event Driven Microservices architecture
 
Introduction To Microservices
Introduction To MicroservicesIntroduction To Microservices
Introduction To Microservices
 
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and HailoMicroservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
 
Effective API Gateway
Effective API GatewayEffective API Gateway
Effective API Gateway
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Event driven architecture
Event driven architectureEvent driven architecture
Event driven architecture
 
Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Pattern
 
Microservices in Practice
Microservices in PracticeMicroservices in Practice
Microservices in Practice
 

Semelhante a Domain Driven Design & Hexagonal Architecture

Wicsa2011 cloud tutorial
Wicsa2011 cloud tutorialWicsa2011 cloud tutorial
Wicsa2011 cloud tutorial
Anna Liu
 
You Name Here1. Explain the difference between hardware and so.docx
You Name Here1. Explain the difference between hardware and so.docxYou Name Here1. Explain the difference between hardware and so.docx
You Name Here1. Explain the difference between hardware and so.docx
jeffevans62972
 
The Cloud Computing Strategy Of Xyz Manufacturing
The Cloud Computing Strategy Of Xyz ManufacturingThe Cloud Computing Strategy Of Xyz Manufacturing
The Cloud Computing Strategy Of Xyz Manufacturing
Mindi Schneider
 

Semelhante a Domain Driven Design & Hexagonal Architecture (20)

MOND Semantics Integration
MOND Semantics IntegrationMOND Semantics Integration
MOND Semantics Integration
 
Building a Hybrid Cloud The Real Deal
Building a Hybrid Cloud The Real DealBuilding a Hybrid Cloud The Real Deal
Building a Hybrid Cloud The Real Deal
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
 
First Steps in Native Cloud Application
First Steps in Native Cloud ApplicationFirst Steps in Native Cloud Application
First Steps in Native Cloud Application
 
Wicsa2011 cloud tutorial
Wicsa2011 cloud tutorialWicsa2011 cloud tutorial
Wicsa2011 cloud tutorial
 
Scanning To Cloud Presentation
Scanning To Cloud PresentationScanning To Cloud Presentation
Scanning To Cloud Presentation
 
You Name Here1. Explain the difference between hardware and so.docx
You Name Here1. Explain the difference between hardware and so.docxYou Name Here1. Explain the difference between hardware and so.docx
You Name Here1. Explain the difference between hardware and so.docx
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Let's talk about... Microservices
Let's talk about... MicroservicesLet's talk about... Microservices
Let's talk about... Microservices
 
GOTO Berlin 2016
GOTO Berlin 2016GOTO Berlin 2016
GOTO Berlin 2016
 
The Cloud Computing Strategy Of Xyz Manufacturing
The Cloud Computing Strategy Of Xyz ManufacturingThe Cloud Computing Strategy Of Xyz Manufacturing
The Cloud Computing Strategy Of Xyz Manufacturing
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
The IBM Cloud
The IBM CloudThe IBM Cloud
The IBM Cloud
 
Cloud Computing and Microsoft
Cloud Computing and MicrosoftCloud Computing and Microsoft
Cloud Computing and Microsoft
 
Enterprise Integration Patterns Revisited (EIP) for the Era of Big Data, Inte...
Enterprise Integration Patterns Revisited (EIP) for the Era of Big Data, Inte...Enterprise Integration Patterns Revisited (EIP) for the Era of Big Data, Inte...
Enterprise Integration Patterns Revisited (EIP) for the Era of Big Data, Inte...
 
Microsoft Microservices
Microsoft MicroservicesMicrosoft Microservices
Microsoft Microservices
 
Forms 2 Future - the ongoing journey into the future for Oracle based organiz...
Forms 2 Future - the ongoing journey into the future for Oracle based organiz...Forms 2 Future - the ongoing journey into the future for Oracle based organiz...
Forms 2 Future - the ongoing journey into the future for Oracle based organiz...
 
AWS re:Invent 2016: [JK REPEAT] The Enterprise Fast Lane - What Your Competit...
AWS re:Invent 2016: [JK REPEAT] The Enterprise Fast Lane - What Your Competit...AWS re:Invent 2016: [JK REPEAT] The Enterprise Fast Lane - What Your Competit...
AWS re:Invent 2016: [JK REPEAT] The Enterprise Fast Lane - What Your Competit...
 
Microservices in the cloud at AutoScout24
Microservices in the cloud at AutoScout24Microservices in the cloud at AutoScout24
Microservices in the cloud at AutoScout24
 
Microservices Architecture for e-Commerce
Microservices Architecture for e-CommerceMicroservices Architecture for e-Commerce
Microservices Architecture for e-Commerce
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Domain Driven Design & Hexagonal Architecture

  • 1. Domain Driven Design & Hexagonal Architecture Handling Complex Business Logic Can Pekdemir
  • 2. About me Expert Software Engineer @iyzico Dokuz Eylul University – Computer Science – 2010 Worked as consultancy in various domains like finance, e-commerce, telecom Speaking at meetups rarely
  • 3. The term Domain Driven Design: Tackling Complexity in the Heart of Software, Eric Evans, 2003
  • 4. Our Biggest Problems Growing Complexity Time to Market
  • 5. General problems in sw development Thinking software development as a cost center rather than a profit center Heavy usage of the latest sexy framework all cool kids talk about Poor collaboration with the business Not giving real emphasis to naming things Wrong abstractions and generalizing solutions unnecessarily by thinking about 5 years later
  • 6. Domain Driven Design An approach for solving complex business problems A mindset of developing business not only software Helps team organization, enterprise architecture, code design Cope with technology challenges ( e.g. Enterprise frameworks, NoSql, Microservices)
  • 8. Exploring the domain with collaboration
  • 9. Hands-on Modelers People who write the code should feel responsible for the model. A modeler should not be separated from implementation.
  • 10. Ubiquitous Language One team, one language No need for translation Use in both communication and in the code
  • 11. Bounded Context A semantic contextual boundary Divide large system into autonomous contexts Be explicit about the context responsibilities Set boundaries and relationships with each other Care about team organization, code bases, database schemas
  • 12. Make sense of Bounded Contexts for your company
  • 13. Strategic Design with Bounded Context Started as a monolithic application More teams operated on the same application Ownership began to blur Shared resources were making it difficult to scale-out “the traditional model is that you take your software to the wall that separates development and operations, and throw it over and then forget about it. Not at Amazon. You build it, you run it.” Werner Vogels, CTO, Amazon, 2006 http://queue.acm.org/detail.cfm?id=1142065
  • 14. Real Numbers Over 6000 employees In 400 cities and 70 countries From 200 engineers to 2000 Engineers only in a year and half 8000 git repositories Over 1000 microservices https://www.youtube.com/watch?v=kb-m2fasdDY What I Wish I Had Known Before Scaling Uber to 1000 Services - Matt Ranney “Scaling the traffic is not the issue. Scaling the team and the product feature release rate is the primary driver.”
  • 15. Context Mapping • Strategic domain driven design • Very useful tool to understand overall architecture and relationships of the system.
  • 17. Anti Corruption Layers Protect your own domain from the dependent contexts Translate unrelated namings into your own domain Protect yourself from others’ failures with timeouts and circuit breakers
  • 18. Integrate Bounded Contexts with Restful API See your API from the consumer’s eyes Do not reflect your entities to restful resources directly Use consumer driven contract libraries ( e.g. PACT, Spring Cloud Contracts )
  • 19. Integrate Bounded Contexts with Messaging Design your domain events regarding your business logic Use at-least-once delivery messaging mechanism Be careful about your receivers to idempotent
  • 20. Aggregates Compose entities and value objects and mark one entity as root Apply consistency boundaries within aggregates Modify and commit only one aggregate instance in one transaction Hint for microservices
  • 22. Aggregate Design Rules Do not let your business logic inside an aggregate leak Design small aggregates Reference by identity only Update other aggregates by eventual consistency ( optional for scalability )
  • 23. Domain Events A record of some business-significant occurence in bounded context Append-only event store mechanisms can be implemented
  • 24. Organize your Code Baklava Code Code with too many layers
  • 25. Hexagonal Architecture Technology free Domain Model “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.” Alistair Cockburn – 2005 Decide on what is inside and outside
  • 26. Benefits Abstracts your business code from technical frameworks Helps you to change your architectural decisions easily Helps doing BDD and TDD
  • 29. References Books - Domain Driven Design: Tackling Complexity in the Heart of Software - Domain Driven Design Distilled - Implementing Domain Driven Design - Building Microservices Links - http://www.codingthearchitecture.com/2016/04/25/layers_hexagons_features_and_components.html - http://alistair.cockburn.us/Hexagonal+architecture - https://www.johndcook.com/blog/2009/07/27/baklav-code/