SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
Brownfield
Domain Driven
Design
Bring your project to the next level
without breaking things (nor people)
About me
@nicolopigna
- PHP developer
- Team leader / Software engineer at Rocket Labs, Berlin
We proudly run Seller Center, the largest Rocket Internet
Marketplace solution.
Popular clients: Zalando (Europe), Lazada (south Asia),
Linio (south America), Global Fashion Group
Why “Brownfield”?
More challenging and fun than greenfield!
Majority of cases.
Open knowledge harder to find.
Examples start from the assumption of a greenfield.
“Greenfield is exciting at first, but taking a brownfield project and
giving it new life, well, is just priceless!”
Me on Twitter
Why Domain Driven Design?
● Non-trivial domain model
● Linguistic boundaries applied to
the code
● Design and code reflect the
same concepts 1:1
● Iterative knowledge distillation
● Both tactical and strategic tools
No, let’s not
CRUDish applications
Generic subdomains
Yes, we can
● In your core domain
● In heavy business-logic
parts of your application
● In strategic supporting
domains
Where should I apply it?
i.e. where you make most of your
money.
Can we outsource or buy it? Then it’s
one of those.
Is it difficult? How do we change?
Team
● learn new concepts
● mindshift is not immediate
● eradicate CRUD design
● design business first, then data
structures
Management
● handle the change
● manage adaptation time
● active part of design process
Organisation
● involve business experts
● face potential change
● introspect processes
Brownfield Domain Driven Design
Your brownfield
Monolithic
High-coupling
Single-data-store
We-tried-to-build-some-unit-tests-but-it’s-impossible-to-mock-
everything-or-refactor-let’s-use-integration-tests-instead.
*all the bad things in this slide are written with Comic Sans and poor contrast on purpose.
Huge
Change-here-break-there
BIG BALL OF “MUD”
BIG BALL OF “MUD”
Hey, at least it works...
Don’t know exactly how, but
it does!
Where to start from?
Ok, we need some Repositores, then a Domain/Model
directory which will contain AggregateRoots, Entity,
ValueObjects, etc.
Yes! Oh, don’t forget about Domain Services, the
Application layer and a new event system which we’ll
definitely need.
What about a new structure for controllers and UI? They’re
definitely part of our Bounded Context! Let’s reuse our DB
connection class, so we also need a Shared Kernel.
Brownfield Domain Driven Design
Instead...
Context mapping
● Define your core domain,
supporting and generic
subdomains
● Define the relations between
them and with other external
systems
● Define behavior at
boundaries and grey areas
Event storming
➔ Describe your business through events, what/who caused them, what is
the “subject” of your events.
➔ Invite the “right people”, brainstorm, discuss, reach a first representation of
your business model. Just let it happen.
DON’T JUST SKIP IT!
Ubiquitous Language
The UL is what takes all things (and people) together.
- It dramatically lowers communication and cognitive load, providing
a common ground, understandable by anyone.
- It defines and explains what domain objects are, how they behave
and the relations between them.
How can you even start coding something that you
haven’t defined in terms of concept and behavior!?
Ok. Finally...
Yeah! We’re finally writing
some code now!
Markers and sticky notes were
making me feel so uncomfortable...
The evil facilitator shouted at
me when I said “cronjob” :’(
We were always talking about
“Product”, but I think I will call this
class “Article”. Buhahaha!
product.name is
varchar(50) or
varchar(255)?
Where should we start applying DDD from?
Are we
confident with
DDD, SOLID
and refactoring
strategies?
Let’s start with our
Core Domain
yes
Did someone at
least read the
Blue and Red
books?
no
yes
no
Let’s start with a
Supporting
Subdomain
Read them...
Keep your UI away
CONTROLLERS
FORMS
TEMPLATES
YOUR FAVORITE
MVC FRAMEWORK
Services
(Endpoint /
Private)
Model
Repositorie
s
Commands
Events
✗
✓
CQRS? Yes, please!
Your database
Command
“Write” Model
● Expresses your business
behavior
● Changes the state of the
system
● Doesn’t expose internal
state
Query
● Shapes information based
on representation type
● Never changes the state of
the system
● Exposes internal state
“Read” Model
Haiku of the code duplication
CQRS is applied,
duplication comes in.
Everything is quiet.
Change your state through events
DoSomethingCommand
Service
Unit Of Work
load($aggregateRootId)
AggregateRoot
doSomething()
AggregateRootAggregateRoot
● Something
Done
Repository
AggregateRootcommit()
flushEvents()
Events
persist($events)
EventBus
post($events)
Event sourcing? Read storage?
IT’S A TRAP!
Event sourcing? Read storage?
1 - Added architectural complexity
Event application
Event replaying
Snapshots
Event sourcing? Read storage?
1 - Added architectural complexity
Event application
Event replaying
Snapshots 2 - Infrastructure and costs
Dedicated data storage (forget MySQL!)
Remote communication (via message
broker, REST interface, etc.)
Event sourcing? Read storage?
1 - Added architectural complexity
Event application
Event replaying
Snapshots 2 - Infrastructure and costs
Dedicated data storage (forget MySQL!)
Remote communication (via message
broker, REST interface, etc.)
3 - Eventual consistency
Think about consequences
Implement resilient behavior
Advanced UI techniques
Oh! Think twice!
Protect your new code!
STRICT RULE: Code from the Big Ball of Mud
must not leak into the new BCs nor vice-versa.
THEN HOW DO THEY
INTERACT? BY MAGIC?
MEET THE
ANTI-CORRUPTION LAYER
MEET THE
ANTI-CORRUPTION LAYER
YOU SHALL NOT PASS!!!
MEET THE
ANTI-CORRUPTION LAYER
YOU SHALL NOT PASS!!! At least, not before I can
convert you to something
meaningful for your
destination context...
Anti-corruption layer
Legacy context
Database
ACL
Adapters
Converters
Identity
Maps
Bounded Context
Anti-corruption layer
Legacy context
Database
ACL
Adapters
Converters
Identity
Maps
I’m here to stay!!!
Bounded Context
Anti-corruption layer
Legacy context
Database
ACL
Bounded Context
Adapters
Converters
Identity
Maps
place
interfaces here
I’m here to stay!!!
Anti-corruption layer
Legacy context
Database
ACL
Adapters
Converters
Identity
Maps
I can fly away, now!
Bounded Context
place
interfaces here
What happens next?
My new shiny BC
Our soon-to-be-shrunk BBoM
Anti-corruption layer
What happens next?
My new shiny BC
Our shrinking BBoM
Anti-corruption layer
My second shiny
BC
What happens next?
My new shiny BC
Our shrinking BBoM
Anti-corruption layer
My second shiny
BC
What happens next?
My new shiny BC
Our shrinking BBoM
Anti-corruption layer
My second shiny
BC
But of course it’s
easier now!
From distributed Bounded Contexts
to μServices
μS = lim Bc(nuc)nuc→ 1
Thank you
for listening!
Time for muddy questions!

Weitere ähnliche Inhalte

Was ist angesagt?

Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Alan Christensen
 
Domain driven design
Domain driven designDomain driven design
Domain driven designits_skm
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroFabrício Rissetto
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignŽilvinas Kuusas
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureCrishantha Nanayakkara
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesRadosław Maziarka
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignNaeem Sarfraz
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design QuicklyMariam Hakobyan
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Richard Langlois P. Eng.
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführungdie.agilen GmbH
 
Domain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledDomain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledNicola Costantino
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
 

Was ist angesagt? (20)

Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
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
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
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
 
Baby steps to Domain-Driven Design
Baby steps to Domain-Driven DesignBaby steps to Domain-Driven Design
Baby steps to Domain-Driven Design
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal Architecture
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and Microservices
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.Microservice Architecture Patterns, by Richard Langlois P. Eng.
Microservice Architecture Patterns, by Richard Langlois P. Eng.
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführung
 
Domain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledDomain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) Distilled
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 

Ähnlich wie Brownfield Domain Driven Design

Php melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyPhp melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyDouglas Reith
 
IT for HR professionals
IT for HR professionalsIT for HR professionals
IT for HR professionalsMiguel Pinto
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introductionAsher Sterkin
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignMuhammad Ali
 
Adopting Domain-Driven Design in your organization
Adopting Domain-Driven Design in your organizationAdopting Domain-Driven Design in your organization
Adopting Domain-Driven Design in your organizationAleix Morgadas
 
Designing Powerful Web Applications - Monterey
Designing Powerful Web Applications - MontereyDesigning Powerful Web Applications - Monterey
Designing Powerful Web Applications - MontereyDave Malouf
 
ASAS 2014 - Simon Brown
ASAS 2014 - Simon BrownASAS 2014 - Simon Brown
ASAS 2014 - Simon BrownAvisi B.V.
 
Microservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedMicroservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedLuram Archanjo
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven DesignAndré Borgonovo
 
DITA and Localization: Bringing the Best Together
DITA and Localization: Bringing the Best TogetherDITA and Localization: Bringing the Best Together
DITA and Localization: Bringing the Best TogetherLavaCon
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDave Malouf
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSAndrea Saltarello
 
Deprecating the state machine: building conversational AI with the Rasa stack
Deprecating the state machine: building conversational AI with the Rasa stackDeprecating the state machine: building conversational AI with the Rasa stack
Deprecating the state machine: building conversational AI with the Rasa stackJustina Petraitytė
 

Ähnlich wie Brownfield Domain Driven Design (20)

Php melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddyPhp melb cqrs-ddd-predaddy
Php melb cqrs-ddd-predaddy
 
IT for HR professionals
IT for HR professionalsIT for HR professionals
IT for HR professionals
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Adopting Domain-Driven Design in your organization
Adopting Domain-Driven Design in your organizationAdopting Domain-Driven Design in your organization
Adopting Domain-Driven Design in your organization
 
Designing Powerful Web Applications - Monterey
Designing Powerful Web Applications - MontereyDesigning Powerful Web Applications - Monterey
Designing Powerful Web Applications - Monterey
 
ASAS 2014 - Simon Brown
ASAS 2014 - Simon BrownASAS 2014 - Simon Brown
ASAS 2014 - Simon Brown
 
Microservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learnedMicroservices as an evolutionary architecture: lessons learned
Microservices as an evolutionary architecture: lessons learned
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
Let's talk about... Microservices
Let's talk about... MicroservicesLet's talk about... Microservices
Let's talk about... Microservices
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Into the domain
Into the domainInto the domain
Into the domain
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
 
DITA and Localization: Bringing the Best Together
DITA and Localization: Bringing the Best TogetherDITA and Localization: Bringing the Best Together
DITA and Localization: Bringing the Best Together
 
Designing Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAsDesigning Powerful Web Applications Using AJAX and Other RIAs
Designing Powerful Web Applications Using AJAX and Other RIAs
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRS
 
Deprecating the state machine: building conversational AI with the Rasa stack
Deprecating the state machine: building conversational AI with the Rasa stackDeprecating the state machine: building conversational AI with the Rasa stack
Deprecating the state machine: building conversational AI with the Rasa stack
 

Kürzlich hochgeladen

UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 

Kürzlich hochgeladen (20)

UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 

Brownfield Domain Driven Design

  • 1. Brownfield Domain Driven Design Bring your project to the next level without breaking things (nor people)
  • 2. About me @nicolopigna - PHP developer - Team leader / Software engineer at Rocket Labs, Berlin We proudly run Seller Center, the largest Rocket Internet Marketplace solution. Popular clients: Zalando (Europe), Lazada (south Asia), Linio (south America), Global Fashion Group
  • 3. Why “Brownfield”? More challenging and fun than greenfield! Majority of cases. Open knowledge harder to find. Examples start from the assumption of a greenfield. “Greenfield is exciting at first, but taking a brownfield project and giving it new life, well, is just priceless!” Me on Twitter
  • 4. Why Domain Driven Design? ● Non-trivial domain model ● Linguistic boundaries applied to the code ● Design and code reflect the same concepts 1:1 ● Iterative knowledge distillation ● Both tactical and strategic tools
  • 5. No, let’s not CRUDish applications Generic subdomains Yes, we can ● In your core domain ● In heavy business-logic parts of your application ● In strategic supporting domains Where should I apply it? i.e. where you make most of your money. Can we outsource or buy it? Then it’s one of those.
  • 6. Is it difficult? How do we change? Team ● learn new concepts ● mindshift is not immediate ● eradicate CRUD design ● design business first, then data structures Management ● handle the change ● manage adaptation time ● active part of design process Organisation ● involve business experts ● face potential change ● introspect processes
  • 9. BIG BALL OF “MUD”
  • 10. BIG BALL OF “MUD” Hey, at least it works... Don’t know exactly how, but it does!
  • 11. Where to start from? Ok, we need some Repositores, then a Domain/Model directory which will contain AggregateRoots, Entity, ValueObjects, etc. Yes! Oh, don’t forget about Domain Services, the Application layer and a new event system which we’ll definitely need. What about a new structure for controllers and UI? They’re definitely part of our Bounded Context! Let’s reuse our DB connection class, so we also need a Shared Kernel.
  • 14. Context mapping ● Define your core domain, supporting and generic subdomains ● Define the relations between them and with other external systems ● Define behavior at boundaries and grey areas
  • 15. Event storming ➔ Describe your business through events, what/who caused them, what is the “subject” of your events. ➔ Invite the “right people”, brainstorm, discuss, reach a first representation of your business model. Just let it happen.
  • 16. DON’T JUST SKIP IT! Ubiquitous Language The UL is what takes all things (and people) together. - It dramatically lowers communication and cognitive load, providing a common ground, understandable by anyone. - It defines and explains what domain objects are, how they behave and the relations between them. How can you even start coding something that you haven’t defined in terms of concept and behavior!?
  • 18. Yeah! We’re finally writing some code now! Markers and sticky notes were making me feel so uncomfortable... The evil facilitator shouted at me when I said “cronjob” :’( We were always talking about “Product”, but I think I will call this class “Article”. Buhahaha! product.name is varchar(50) or varchar(255)?
  • 19. Where should we start applying DDD from? Are we confident with DDD, SOLID and refactoring strategies? Let’s start with our Core Domain yes Did someone at least read the Blue and Red books? no yes no Let’s start with a Supporting Subdomain Read them...
  • 20. Keep your UI away CONTROLLERS FORMS TEMPLATES YOUR FAVORITE MVC FRAMEWORK Services (Endpoint / Private) Model Repositorie s Commands Events ✗ ✓
  • 21. CQRS? Yes, please! Your database Command “Write” Model ● Expresses your business behavior ● Changes the state of the system ● Doesn’t expose internal state Query ● Shapes information based on representation type ● Never changes the state of the system ● Exposes internal state “Read” Model
  • 22. Haiku of the code duplication CQRS is applied, duplication comes in. Everything is quiet.
  • 23. Change your state through events DoSomethingCommand Service Unit Of Work load($aggregateRootId) AggregateRoot doSomething() AggregateRootAggregateRoot ● Something Done Repository AggregateRootcommit() flushEvents() Events persist($events) EventBus post($events)
  • 24. Event sourcing? Read storage? IT’S A TRAP!
  • 25. Event sourcing? Read storage? 1 - Added architectural complexity Event application Event replaying Snapshots
  • 26. Event sourcing? Read storage? 1 - Added architectural complexity Event application Event replaying Snapshots 2 - Infrastructure and costs Dedicated data storage (forget MySQL!) Remote communication (via message broker, REST interface, etc.)
  • 27. Event sourcing? Read storage? 1 - Added architectural complexity Event application Event replaying Snapshots 2 - Infrastructure and costs Dedicated data storage (forget MySQL!) Remote communication (via message broker, REST interface, etc.) 3 - Eventual consistency Think about consequences Implement resilient behavior Advanced UI techniques
  • 29. Protect your new code! STRICT RULE: Code from the Big Ball of Mud must not leak into the new BCs nor vice-versa. THEN HOW DO THEY INTERACT? BY MAGIC?
  • 32. MEET THE ANTI-CORRUPTION LAYER YOU SHALL NOT PASS!!! At least, not before I can convert you to something meaningful for your destination context...
  • 35. Anti-corruption layer Legacy context Database ACL Bounded Context Adapters Converters Identity Maps place interfaces here I’m here to stay!!!
  • 36. Anti-corruption layer Legacy context Database ACL Adapters Converters Identity Maps I can fly away, now! Bounded Context place interfaces here
  • 37. What happens next? My new shiny BC Our soon-to-be-shrunk BBoM Anti-corruption layer
  • 38. What happens next? My new shiny BC Our shrinking BBoM Anti-corruption layer My second shiny BC
  • 39. What happens next? My new shiny BC Our shrinking BBoM Anti-corruption layer My second shiny BC
  • 40. What happens next? My new shiny BC Our shrinking BBoM Anti-corruption layer My second shiny BC But of course it’s easier now!
  • 41. From distributed Bounded Contexts to μServices μS = lim Bc(nuc)nuc→ 1
  • 42. Thank you for listening! Time for muddy questions!

Hinweis der Redaktion

  1. ...which means that transitions should never be painful, cause troubles nor resulting in neverending refactoring sessions.
  2. SC bootstrapped in 3 months, features added one after another, thus resulting now in some problems controlling the codebase and solving bugs.
  3. hands up people working on projects younger than 6 months. now older. from the latter, who thinks that their codebase already need some refactoring / has problems.
  4. what is a supporting subdomain. what is a generic subdomain. why not in crudish apps
  5. stress “don’t start designing from data”. stress on “introspect processes” to introduce the next Matrix slide.
  6. ask
  7. Stress on why CQRS is a “natural” good choice. Explain the differences btw simplified and “full” cqrs architecture