1
Domain Driven
Design
Strategic design & Microservices
http://radblog.pl/DDD
2
WHY
SHOULD
YOU
EVEN
CARE?
3
radblog.pl @RadekMaziarkaobjectivity.co.uk
Radek Maziarka
4
5
Monolith Microservices
6
Modularity – the final frontierŁukasz Szydło at Boiling Frogs 2018
NO YES
NO Monolith
YES Microservices
DISTRIBUTED
MODULAR
Distributed Monolith
7
Ecommerce platform
Multiple areas in selling products
NOTIFICATIONS
DELIVERY
PRODUCT
MANAGEMENT
ORDERSSTORE
ACCOUNTS
8
Splitting Monolith by distributionMost common transition to microservices
Store
Func 2
Account
Func 2
Delivery
Func 1
Store
Func 3
Delivery
Func 2
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 1
Store
Func 1
Order
Func 2
Account
Func 3
All Func
in one DB
Delivery
Func 2
Store
Func 3
Delivery
Func 3
App
2-Func DB
Order
Func 1
Order
Func 3
Account
Func 2
2-Func DB
Store
Func 2
Delivery
Func 1
Account
Func 1
3-Func DB
Order
Func 2
Store
Func 1
Account
Func 3
3-Func DB
Service 1 Service 2
Service 3 Service 4
9
Monolith splitted by distributionMicroservices fitness check
3
TRANSACTION INSIDE
SERVICE
BUSINESS FOCUSED SERVICES
SINGLE DATA OWNERSHIP2
1
Delivery
Func 2
Store
Func 3
Delivery
Func 3
2-Func DB
Order
Func 1
Order
Func 3
Account
Func 2
2-Func DB
Store
Func 2
Delivery
Func 1
Account
Func 1
3-Func DB
Order
Func 2
Store
Func 1
Account
Func 3
3-Func DB
Service 1 Service 2
Service 3 Service 4
4 INDEPENDENT DEPLOYMENTS
Func mix in one DB
V2 V2
V2
10
Distributed MonolithDisadvantages of distributed big ball of mud
3
DISTRIBUTED TRANSACTION
MIXED SERVICES
NO DATA OWNERSHIP2
1
Delivery
Func 2
Store
Func 3
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 2
Delivery
Func 1
Account
Func 1
Order
Func 2
Store
Func 1
Account
Func 3
4 DEPENDENT DEPLOYMENTS
2-Func DB 2-Func DB
3-Func DB 3-Func DB
Service 1 Service 2
Service 3 Service 4
11
Distributed Monolith - articlesWhy you should not take this step
12
JAKUB NABRDALIK
MICROSERVICES ARE
TECHNICAL SOLUTION
And developers love technical solutions
Conway’s revenge - Bydgoszcz JUG - https://www.youtube.com/watch?v=UhIIpUQ-i38
Mentor in Bottega IT Solution
13
14
Modularity – the final frontierŁukasz Szydło at Boiling Frogs 2018
NO YES
NO Monolith
YES Microservices
DISTRIBUTED
MODULAR
Modular Monolith
Distributed Monolith
DDD
15
Domain Driven Design
Tactical patternsStrategic design
Aggregates
Repositories
Entities
Services
Events
Dependency Injection
Modules
Factories
Layers
Core domain
Sub-domain
DomainUbiquitous Language
Domain model
Context Map
Context
Generic Subdomain
Bounded Context
17
Domain Driven Design
In ecommerce domain
18
UBIQUITOUS
LANGUAGE
19
3
ADD ORDER
UPDATE SHIPPING
2
1
Customer storiesClient actions in a store
4 ITEMS COLLECTION
DELETE ORDER
20
3
SPOKEN LANGUAGE MUST
REFER TO BUSINESS
LANGUAGE WILL EVOLVE WITH
UNDERSTANDING DOMAIN
SHARED LANGUAGE FROM BUSINESS
TO CODEBASE2
1
Shared understandingCommon language between people
User Client
Add order Place order
Update delivery Change delivery date
Items collection Product catalogue
Fast shipping Express delivery
21
Deeper understanding
of business
Code adjusted
to business needs
Better cooperation
with the client
Ubiquitous LanguageBenefits of using UL
22
BOUNDED
CONTEXT
23
ShippingIn online store platform
3
CRUCIAL CONTEXT
CLIENT WILL FOCUS ON IT
GENERATE A LOT OF MONEY2
1
24
3
CORE DOMAINS
GENERIC SUBDOMAINS
SUPPORTING SUBDOMAINS2
1
Different importanceDomains are not equally significant
Orders
Store
Delivery
Notifications
Account
25
User in ecommerce contextDifferent meanings of users
ACCOUNTSDELIVERYSTORE ORDERS
• Shopper who looks for a
products
• Can add products to
basket
• Customer who bought
placed order
• Can change payment
• User in store account
• Can check personal data
• Recipient who gets
delivery
• Can change change
delivery address
26
3
LOGICAL BOUNDARY
BETWEEN UNDERSTANDINGS
UNIFIED MODEL DOES NOT EXISTS
DIFFERENT MODEL FUNCTIONS
AND DATA STRUCTURE2
1
Bounded contextThings has different meaning between contexts
CustomerOrder
Payment
Products
Recipient Delivery
Company
Address
Orders Delivery
27
Modules divided from
business perspective
Solution adjusted
to use-case
Team bounded
to single context
Bounded ContextBenefits of using BC
28
CONTEXT
MAP
29
3
DIFFERENT WAYS OF
INTEGRATIONS
SEPARATE WAYS AS
INTEGRATION APPROACH
TRANSLATIONS BETWEEN
CONTEXT2
1
Context mapApproaches of communications between contexts
Orders
Store
Shipping
Notifications
Down
Up
Shared Kernel Shared Kernel
Layer
Partnership
Legacy
Reporting
Separate
Ways
30
More effective integration
between contexts
Better informed
decisions
Organized, business
architecture
Context MapBenefits of using CM
31
32
Monolith -> Modular MonolithLess common transition to microservices
Store
Func 2
Account
Func 2
Delivery
Func 1
Store
Func 3
Delivery
Func 2
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 1
Order
Func 2
Account
Func 3
All Func in
one DB
Delivery
Func 2
Delivery
Func 3
Delivery
Func 3
App
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 2
Store
Func 3
Store
Func 1
Modules inside DB
Account
Func 2
Account
Func 1
Account
Func 3
Store Module Account Module
Delivery Module Order Module
App
33
Modular Monolith -> MicroservicesTransition to microservices step by step
Delivery
Func 2
Delivery
Func 3
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 2
Store
Func 3
Store
Func 1
Modules inside DB
Account
Func 2
Account
Func 1
Account
Func 3
App 1
Delivery
Func 2
Delivery
Func 3
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 2
Store
Func 3
Store
Func 1
Modules inside DB
Account
Func 2
Account
Func 1
Account
Func 3
App
Store DB
Delivery DB
Store Module Account Module
Delivery Module Order Module
Store Service Account Module
Delivery Service Order Module
34
Monolith splitted by modularizationMicroservices fitness check
Delivery
Func 2
Delivery
Func 3
Delivery
Func 3
Order
Func 1
Order
Func 3
Account
Func 2
Store
Func 2
Store
Func 3
Store
Func 1
Account
Func 2
Account
Func 1
Account
Func 3
Store DB
Delivery DB
Account DB
Order DB
3
TRANSACTION INSIDE
SERVICE
BUSINESS FOCUSED SERVICES
SINGLE DATA OWNERSHIP2
1
4 INDEPENDENT DEPLOYMENTS
Store Service Account Service
Delivery Service Order Service
35
Microservices DDD
36
radblog.pl/DDD
Articles:
•Weronika Łabaj - DDD Ultra-Lite
•Herberto Graca - Domain-Driven Design
•Carbon Five - Ubiquitous Language & the joy of naming
•Sapiens Work - DDD - The Bounded Context Explained
•Philip Brown - Strategies for Integrating Bounded Contexts
•Sebastian Gębski - The awesomeness of Modular Monolith
•Microsoft - Tackling Business Complexity in a Microservice with DDD and CQRS Patterns
•Berke Sokhan - Domain Driven Design for Services Architecture
Videos:
•DevTalk - DDD with Sławomir Sobótka
•DevTalk Trio - DDD
•Domain Driven Design: The Good Parts - Jimmy Bogard
•What is Domain Driven Design?
•DDD & Microservices: At Last, Some Boundaries!
•7 Reasons Why DDD Projects Fail
Books:
•Eric Evans - Domain Driven Design
•Vernon Vaughn - Implementing Domain-Driven Design
•Vernon Vaughn - Domain-Driven Design Distilled
•Sam Newman - Building Microservices: Designing Fine-Grained
Systems
37
radblog.pl/DDD
radblog.pl/DDD-form

Domain Driven Design - Strategic Patterns and Microservices

  • 1.
    1 Domain Driven Design Strategic design& Microservices http://radblog.pl/DDD
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
    6 Modularity – thefinal frontierŁukasz Szydło at Boiling Frogs 2018 NO YES NO Monolith YES Microservices DISTRIBUTED MODULAR Distributed Monolith
  • 7.
    7 Ecommerce platform Multiple areasin selling products NOTIFICATIONS DELIVERY PRODUCT MANAGEMENT ORDERSSTORE ACCOUNTS
  • 8.
    8 Splitting Monolith bydistributionMost common transition to microservices Store Func 2 Account Func 2 Delivery Func 1 Store Func 3 Delivery Func 2 Delivery Func 3 Order Func 1 Order Func 3 Account Func 1 Store Func 1 Order Func 2 Account Func 3 All Func in one DB Delivery Func 2 Store Func 3 Delivery Func 3 App 2-Func DB Order Func 1 Order Func 3 Account Func 2 2-Func DB Store Func 2 Delivery Func 1 Account Func 1 3-Func DB Order Func 2 Store Func 1 Account Func 3 3-Func DB Service 1 Service 2 Service 3 Service 4
  • 9.
    9 Monolith splitted bydistributionMicroservices fitness check 3 TRANSACTION INSIDE SERVICE BUSINESS FOCUSED SERVICES SINGLE DATA OWNERSHIP2 1 Delivery Func 2 Store Func 3 Delivery Func 3 2-Func DB Order Func 1 Order Func 3 Account Func 2 2-Func DB Store Func 2 Delivery Func 1 Account Func 1 3-Func DB Order Func 2 Store Func 1 Account Func 3 3-Func DB Service 1 Service 2 Service 3 Service 4 4 INDEPENDENT DEPLOYMENTS Func mix in one DB V2 V2 V2
  • 10.
    10 Distributed MonolithDisadvantages ofdistributed big ball of mud 3 DISTRIBUTED TRANSACTION MIXED SERVICES NO DATA OWNERSHIP2 1 Delivery Func 2 Store Func 3 Delivery Func 3 Order Func 1 Order Func 3 Account Func 2 Store Func 2 Delivery Func 1 Account Func 1 Order Func 2 Store Func 1 Account Func 3 4 DEPENDENT DEPLOYMENTS 2-Func DB 2-Func DB 3-Func DB 3-Func DB Service 1 Service 2 Service 3 Service 4
  • 11.
    11 Distributed Monolith -articlesWhy you should not take this step
  • 12.
    12 JAKUB NABRDALIK MICROSERVICES ARE TECHNICALSOLUTION And developers love technical solutions Conway’s revenge - Bydgoszcz JUG - https://www.youtube.com/watch?v=UhIIpUQ-i38 Mentor in Bottega IT Solution
  • 13.
  • 14.
    14 Modularity – thefinal frontierŁukasz Szydło at Boiling Frogs 2018 NO YES NO Monolith YES Microservices DISTRIBUTED MODULAR Modular Monolith Distributed Monolith DDD
  • 15.
    15 Domain Driven Design TacticalpatternsStrategic design Aggregates Repositories Entities Services Events Dependency Injection Modules Factories Layers Core domain Sub-domain DomainUbiquitous Language Domain model Context Map Context Generic Subdomain Bounded Context
  • 16.
  • 17.
  • 18.
    19 3 ADD ORDER UPDATE SHIPPING 2 1 CustomerstoriesClient actions in a store 4 ITEMS COLLECTION DELETE ORDER
  • 19.
    20 3 SPOKEN LANGUAGE MUST REFERTO BUSINESS LANGUAGE WILL EVOLVE WITH UNDERSTANDING DOMAIN SHARED LANGUAGE FROM BUSINESS TO CODEBASE2 1 Shared understandingCommon language between people User Client Add order Place order Update delivery Change delivery date Items collection Product catalogue Fast shipping Express delivery
  • 20.
    21 Deeper understanding of business Codeadjusted to business needs Better cooperation with the client Ubiquitous LanguageBenefits of using UL
  • 21.
  • 22.
    23 ShippingIn online storeplatform 3 CRUCIAL CONTEXT CLIENT WILL FOCUS ON IT GENERATE A LOT OF MONEY2 1
  • 23.
    24 3 CORE DOMAINS GENERIC SUBDOMAINS SUPPORTINGSUBDOMAINS2 1 Different importanceDomains are not equally significant Orders Store Delivery Notifications Account
  • 24.
    25 User in ecommercecontextDifferent meanings of users ACCOUNTSDELIVERYSTORE ORDERS • Shopper who looks for a products • Can add products to basket • Customer who bought placed order • Can change payment • User in store account • Can check personal data • Recipient who gets delivery • Can change change delivery address
  • 25.
    26 3 LOGICAL BOUNDARY BETWEEN UNDERSTANDINGS UNIFIEDMODEL DOES NOT EXISTS DIFFERENT MODEL FUNCTIONS AND DATA STRUCTURE2 1 Bounded contextThings has different meaning between contexts CustomerOrder Payment Products Recipient Delivery Company Address Orders Delivery
  • 26.
    27 Modules divided from businessperspective Solution adjusted to use-case Team bounded to single context Bounded ContextBenefits of using BC
  • 27.
  • 28.
    29 3 DIFFERENT WAYS OF INTEGRATIONS SEPARATEWAYS AS INTEGRATION APPROACH TRANSLATIONS BETWEEN CONTEXT2 1 Context mapApproaches of communications between contexts Orders Store Shipping Notifications Down Up Shared Kernel Shared Kernel Layer Partnership Legacy Reporting Separate Ways
  • 29.
    30 More effective integration betweencontexts Better informed decisions Organized, business architecture Context MapBenefits of using CM
  • 30.
  • 31.
    32 Monolith -> ModularMonolithLess common transition to microservices Store Func 2 Account Func 2 Delivery Func 1 Store Func 3 Delivery Func 2 Delivery Func 3 Order Func 1 Order Func 3 Account Func 2 Store Func 1 Order Func 2 Account Func 3 All Func in one DB Delivery Func 2 Delivery Func 3 Delivery Func 3 App Order Func 1 Order Func 3 Account Func 2 Store Func 2 Store Func 3 Store Func 1 Modules inside DB Account Func 2 Account Func 1 Account Func 3 Store Module Account Module Delivery Module Order Module App
  • 32.
    33 Modular Monolith ->MicroservicesTransition to microservices step by step Delivery Func 2 Delivery Func 3 Delivery Func 3 Order Func 1 Order Func 3 Account Func 2 Store Func 2 Store Func 3 Store Func 1 Modules inside DB Account Func 2 Account Func 1 Account Func 3 App 1 Delivery Func 2 Delivery Func 3 Delivery Func 3 Order Func 1 Order Func 3 Account Func 2 Store Func 2 Store Func 3 Store Func 1 Modules inside DB Account Func 2 Account Func 1 Account Func 3 App Store DB Delivery DB Store Module Account Module Delivery Module Order Module Store Service Account Module Delivery Service Order Module
  • 33.
    34 Monolith splitted bymodularizationMicroservices fitness check Delivery Func 2 Delivery Func 3 Delivery Func 3 Order Func 1 Order Func 3 Account Func 2 Store Func 2 Store Func 3 Store Func 1 Account Func 2 Account Func 1 Account Func 3 Store DB Delivery DB Account DB Order DB 3 TRANSACTION INSIDE SERVICE BUSINESS FOCUSED SERVICES SINGLE DATA OWNERSHIP2 1 4 INDEPENDENT DEPLOYMENTS Store Service Account Service Delivery Service Order Service
  • 34.
  • 35.
    36 radblog.pl/DDD Articles: •Weronika Łabaj -DDD Ultra-Lite •Herberto Graca - Domain-Driven Design •Carbon Five - Ubiquitous Language & the joy of naming •Sapiens Work - DDD - The Bounded Context Explained •Philip Brown - Strategies for Integrating Bounded Contexts •Sebastian Gębski - The awesomeness of Modular Monolith •Microsoft - Tackling Business Complexity in a Microservice with DDD and CQRS Patterns •Berke Sokhan - Domain Driven Design for Services Architecture Videos: •DevTalk - DDD with Sławomir Sobótka •DevTalk Trio - DDD •Domain Driven Design: The Good Parts - Jimmy Bogard •What is Domain Driven Design? •DDD & Microservices: At Last, Some Boundaries! •7 Reasons Why DDD Projects Fail Books: •Eric Evans - Domain Driven Design •Vernon Vaughn - Implementing Domain-Driven Design •Vernon Vaughn - Domain-Driven Design Distilled •Sam Newman - Building Microservices: Designing Fine-Grained Systems
  • 36.

Editor's Notes

  • #10 - Being closely aligned to business DDD results in better mapping client’s needs to product. - DDD focuces on creating common understanding between project’s parties. - DDD strategies allows to create more modular and maintable application.
  • #11 - Being closely aligned to business DDD results in better mapping client’s needs to product. - DDD focuces on creating common understanding between project’s parties. - DDD strategies allows to create more modular and maintable application.
  • #14 - Being closely aligned to business DDD results in better mapping client’s needs to product. - DDD focuces on creating common understanding between project’s parties. - DDD strategies allows to create more modular and maintable application.
  • #27 - - Każdy dział będzie - Nie da się stworzyc jednorodnego modelu ponieważ rzeczywistość nie jest jednorodna.