SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
From ddd
to DDD
An ongoing journey
Thibaud Desodt - @tsimbalar
What this is about
• Me, myself and I
• Code
• Architecture
• Learning process
Where it all started
E-commerce site
ASP.NET / C#
Back-office site
“classic” ASP / VbScript
Data
Tables
Stored Procedures
T-SQL
PRESENTATION
BUSINESS LOGIC
DATA
And it was …
• Not super pleasant
• VbScript
• T-SQL
• Fragile
• No automated tests
• Tight coupling
• Schema -> Stored Procs -> Website / admin site
… but it worked “well enough”!
• Customer value
• Happy customer
• Fast delivery of features
• Reasonable perf
• Easy to work on
• 1 feature ≈ 1 stored procedure
It worked well ... in that context
• Working alone on project
• Version 1 of the product
• Well-defined requirements
• Tight interactions with customer
• Simple domain
= ideal greenfield project
A few years later …
Similar approach, different context
A different context
• 40,000+ employees company
• 100s of developers spread across the globe
• Many different systems accessing the database(s)
This scripts that runs
every night
That excel sheet
nobody understands
Admin CRUD app
Quotation app
Data
800+ Tables
3000+ Stored Procedures
T-SQL
Customer-facing web appsB2B SOAP services
Internal Catalogue app
Reporting App
Bob running random
SQL queries
The Enterprise Database ™
Many issues
• Evolution is hard
• Testing is hard
• Versioning / collaboration is hard
• Performance is not great
the “solution” ….
• Team of 50 DBAs
• The “database” committee
• The “database” change process
• The “meta-database”
• Db replication
• Governance
Technical solutions
… to solve technical issues
… introduced because of technical decisions
… with no value to the users
= Accidental complexity
Moving away from database-driven
• Persistence is an implementation detail
• Focus on customer value
Relational DB, Document DB, Key-Value store, file …
Who cares ?
Business > Tech
App
PRESENTATION
DATA
BUSINESS LOGIC
PRESENTATION
DATA
BUSINESS LOGIC
Bringing the logic back to the code
Bringing the logic back to the code
• No more Stored Procedures
• ORM (Entity Framework in that case)
• Data-access code + Entities* generated from database
* Not quite
Status
That’s better !
• No more business logic in the DB
• Quite readable
Still a bit messy:
• Not testable
• Hard coupling
DATA
BUSINESS
LOGIC
Better layering
DATA
BUSINESS LOGIC
Better layering
Services
Repositories
+ Unit of Work Abstract away details of how
data is accessed
Orchestrate data-flow for a
given use-case
Repository
A “Service”
Status
Quite an improvement
• Decoupled
• Testable
• Easy to know where
functionality should live
• It worked fine initially
But … wait a minute …
Object graphs
When loading an
Order from DB …what
else should I load ?
- All the relationships ?
- Some of them, and leave some
unpopulated (null) ?
- Some of them, and use lazy-
loading ?
define Aggregates
Deliberately delimit clusters of objects that
live together and are loaded/stored together.
… keep them as small as possible
Object graphs
identify the Aggregate Root
The unique entry point to the graph
Dependencies go only in one direction
Repositories return Aggregates through their root
More smells …
Transaction Script
Anemic Domain Model
Fighting the Anemic Domain Model
• Do not expose setters
• Do expose only the Aggregate Root
• Do enforce invariants (guard clauses)
• Do mutations only through methods
• Use intent-revealing names (no Update(…) methods)
Make invalid states
impossible to represent
Transaction Script -> Application Service
1. Load
aggregate root
from repository
2. Mutate by
invoking methods
3. Save to DB
Methods on Domain Entities
Intent-revealing
name
Make forbidden
state impossible
Avoid primitive
types
Status
Even better
• Decoupled
• Testable
• Easy to know where
functionality should live
• Explicit models and methods
• Clean encapsulation
• Meaningful names
PRESENTATION
DATA
Application Services
Repositories
Aggregates
What about views ?
We defined
• Small aggregates
• Repositories targeting only
Aggregate Roots
• Transactional consistency
• Repositories hiding data-access
For views / reports we need
• JOINs across many tables
• Small ad-hoc queries on some
tables
• No transactions
• Access to raw data / perf
Different needs require different tools
Separating Reads and Writes
• Commands vs Queries
• Write Model vs Read Model
CQS (Command Query Separation)
CQRS (Command Query Responsibility Segregation)
Aggregates View-specific projections
As big or small as needed
WRITE
READ
Commands
Application Service
Repository
Commands
Commands
1. Load aggregate
from repository
2. Validate / mutate
3. Save changes
Direct
access to
the data
Queries
QueriesQueries
Query Handler
*
* Maybe same as primary, maybe totally
different
Expose only
Aggregates
Write Model Read Model
Allow edits
Read-only
Expose
projections, DTOs
tailored for the
view
Status
Good enough for now ☺
• Decoupled
• Testable
• Easy to know where functionality
should live
• Explicit models and methods
• Clean encapsulation
• Meaningful names
• Correct writes
• Fast Reads
Take aways
• Smoothly introduce DDD
concepts
• Failing is learning
• Watch out for smells
• Continuously improve
• The right tool for the right job
• Context is king
Going further
Some important concepts I left out :
• Value Objects
• Bounded Contexts
• Ubiquitous Language
• Domain Events
• Context Mapping
• …
Thanks for listening !
Questions ? Thibaud Desodt - @tsimbalar

Contenu connexe

Tendances

Introduction to Digital Financial Services
Introduction to Digital Financial ServicesIntroduction to Digital Financial Services
Introduction to Digital Financial ServicesCGAP
 
System architecture for central banks
System architecture for central banksSystem architecture for central banks
System architecture for central banksJean-Marc Lepain
 
Scaling Agile with JIRA Software and Portfolio for JIRA
Scaling Agile with JIRA Software and Portfolio for JIRAScaling Agile with JIRA Software and Portfolio for JIRA
Scaling Agile with JIRA Software and Portfolio for JIRAAtlassian
 
E property project documentation
E property project documentationE property project documentation
E property project documentationMusakkhir Sayyed
 
Epics and User Stories
Epics and User StoriesEpics and User Stories
Epics and User StoriesMilind Gokhale
 
Banking Management System Report .docx
Banking Management System Report .docxBanking Management System Report .docx
Banking Management System Report .docxShubham Jaybhaye
 
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)Amazon Web Services Korea
 
Loan Origination Reference Architecture Deep Dive
Loan Origination Reference Architecture Deep DiveLoan Origination Reference Architecture Deep Dive
Loan Origination Reference Architecture Deep DiveMike Walker
 
Implementing security requirements for banking API system using Open Source ...
 Implementing security requirements for banking API system using Open Source ... Implementing security requirements for banking API system using Open Source ...
Implementing security requirements for banking API system using Open Source ...Yuichi Nakamura
 
Payments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewPayments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewAkshay Kaul
 
Table of contents on blood bank management system
Table of contents on blood bank management systemTable of contents on blood bank management system
Table of contents on blood bank management systemJawhar Ali
 
We Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge ArchitectureWe Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge ArchitectureApigee | Google Cloud
 
eCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductioneCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductionAidanChard
 
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph Database
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph DatabaseTelecoms Service Assurance & Service Fulfillment with Neo4j Graph Database
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph DatabaseNeo4j
 
SME Neo-banks - Global Overview | Fintech Fraternity
SME Neo-banks - Global Overview | Fintech FraternitySME Neo-banks - Global Overview | Fintech Fraternity
SME Neo-banks - Global Overview | Fintech FraternityFintech Fraternity
 
What is APIGEE? What are the benefits of APIGEE?
What is APIGEE? What are the benefits of APIGEE?What is APIGEE? What are the benefits of APIGEE?
What is APIGEE? What are the benefits of APIGEE?IQ Online Training
 

Tendances (20)

Introduction to Digital Financial Services
Introduction to Digital Financial ServicesIntroduction to Digital Financial Services
Introduction to Digital Financial Services
 
System architecture for central banks
System architecture for central banksSystem architecture for central banks
System architecture for central banks
 
Scaling Agile with JIRA Software and Portfolio for JIRA
Scaling Agile with JIRA Software and Portfolio for JIRAScaling Agile with JIRA Software and Portfolio for JIRA
Scaling Agile with JIRA Software and Portfolio for JIRA
 
E property project documentation
E property project documentationE property project documentation
E property project documentation
 
Epics and User Stories
Epics and User StoriesEpics and User Stories
Epics and User Stories
 
Banking Management System Report .docx
Banking Management System Report .docxBanking Management System Report .docx
Banking Management System Report .docx
 
Apigee Edge Product Demo
Apigee Edge Product DemoApigee Edge Product Demo
Apigee Edge Product Demo
 
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)
Apache MXNet으로 배워보는 딥러닝(Deep Learning) - 김무현 (AWS 솔루션즈아키텍트)
 
Loan Origination Reference Architecture Deep Dive
Loan Origination Reference Architecture Deep DiveLoan Origination Reference Architecture Deep Dive
Loan Origination Reference Architecture Deep Dive
 
Implementing security requirements for banking API system using Open Source ...
 Implementing security requirements for banking API system using Open Source ... Implementing security requirements for banking API system using Open Source ...
Implementing security requirements for banking API system using Open Source ...
 
Payments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian OverviewPayments and transaction processing systems - Global and Indian Overview
Payments and transaction processing systems - Global and Indian Overview
 
Table of contents on blood bank management system
Table of contents on blood bank management systemTable of contents on blood bank management system
Table of contents on blood bank management system
 
Auditing in the Age of AI
Auditing in the Age of AIAuditing in the Age of AI
Auditing in the Age of AI
 
We Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge ArchitectureWe Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge Architecture
 
Fintech – financial technology v01 18 apr-2016
Fintech – financial technology v01 18 apr-2016Fintech – financial technology v01 18 apr-2016
Fintech – financial technology v01 18 apr-2016
 
eCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductioneCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An Introduction
 
Credit Karma
Credit KarmaCredit Karma
Credit Karma
 
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph Database
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph DatabaseTelecoms Service Assurance & Service Fulfillment with Neo4j Graph Database
Telecoms Service Assurance & Service Fulfillment with Neo4j Graph Database
 
SME Neo-banks - Global Overview | Fintech Fraternity
SME Neo-banks - Global Overview | Fintech FraternitySME Neo-banks - Global Overview | Fintech Fraternity
SME Neo-banks - Global Overview | Fintech Fraternity
 
What is APIGEE? What are the benefits of APIGEE?
What is APIGEE? What are the benefits of APIGEE?What is APIGEE? What are the benefits of APIGEE?
What is APIGEE? What are the benefits of APIGEE?
 

Similaire à From ddd to DDD : My journey from data-driven development to Domain-Driven Design

Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Lucas Jellema
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationAndrew Siemer
 
Webinar: Migrating from RDBMS to MongoDB
Webinar: Migrating from RDBMS to MongoDBWebinar: Migrating from RDBMS to MongoDB
Webinar: Migrating from RDBMS to MongoDBMongoDB
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureThomas Jaskula
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLEDB
 
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...GoQA
 
CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011Dennis Traub
 
Transform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big DataTransform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big DataAshnikbiz
 
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...Lucas Jellema
 
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoStateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoRedis Labs
 
Dbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoDbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoAgile Connect®
 
Got documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionGot documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionMaggie Pint
 
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...Trivadis
 
From Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivAndrzej Krzywda
 
Demystifying data engineering
Demystifying data engineeringDemystifying data engineering
Demystifying data engineeringThang Bui (Bob)
 
Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)Bradford Stephens
 

Similaire à From ddd to DDD : My journey from data-driven development to Domain-Driven Design (20)

Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
 
Einführung in RavenDB
Einführung in RavenDBEinführung in RavenDB
Einführung in RavenDB
 
Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregation
 
Webinar: Migrating from RDBMS to MongoDB
Webinar: Migrating from RDBMS to MongoDBWebinar: Migrating from RDBMS to MongoDB
Webinar: Migrating from RDBMS to MongoDB
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...
ГАННА КАПЛУН «noSQL vs SQL: порівняння використання реляційних та нереляційни...
 
CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011
 
Transform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big DataTransform your DBMS to drive engagement innovation with Big Data
Transform your DBMS to drive engagement innovation with Big Data
 
Scaling tappsi
Scaling tappsiScaling tappsi
Scaling tappsi
 
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...
50 Shades of Data - how, when and why Big, Fast, Relational, NoSQL, Elastic, ...
 
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk ChoStateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
 
Dbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoDbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo Piairo
 
DbOps, DevOps and Ops
DbOps, DevOps and OpsDbOps, DevOps and Ops
DbOps, DevOps and Ops
 
Got documents - The Raven Bouns Edition
Got documents - The Raven Bouns EditionGot documents - The Raven Bouns Edition
Got documents - The Raven Bouns Edition
 
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
 
From Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, Lviv
 
Demystifying data engineering
Demystifying data engineeringDemystifying data engineering
Demystifying data engineering
 
Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)
 
Beyond The Rails Way
Beyond The Rails WayBeyond The Rails Way
Beyond The Rails Way
 

Dernier

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...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%+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
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2
 
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 SituationJuha-Pekka Tolvanen
 
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 ProgramWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
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 TransformationWSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%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 sowetomasabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
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
 

Dernier (20)

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...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+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...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
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 - 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
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
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
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
 
%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
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
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...
 

From ddd to DDD : My journey from data-driven development to Domain-Driven Design

  • 1. From ddd to DDD An ongoing journey Thibaud Desodt - @tsimbalar
  • 2. What this is about • Me, myself and I • Code • Architecture • Learning process
  • 3. Where it all started
  • 4. E-commerce site ASP.NET / C# Back-office site “classic” ASP / VbScript Data Tables Stored Procedures T-SQL PRESENTATION BUSINESS LOGIC DATA
  • 5. And it was … • Not super pleasant • VbScript • T-SQL • Fragile • No automated tests • Tight coupling • Schema -> Stored Procs -> Website / admin site
  • 6. … but it worked “well enough”! • Customer value • Happy customer • Fast delivery of features • Reasonable perf • Easy to work on • 1 feature ≈ 1 stored procedure
  • 7. It worked well ... in that context • Working alone on project • Version 1 of the product • Well-defined requirements • Tight interactions with customer • Simple domain = ideal greenfield project
  • 8. A few years later … Similar approach, different context
  • 9. A different context • 40,000+ employees company • 100s of developers spread across the globe • Many different systems accessing the database(s)
  • 10. This scripts that runs every night That excel sheet nobody understands Admin CRUD app Quotation app Data 800+ Tables 3000+ Stored Procedures T-SQL Customer-facing web appsB2B SOAP services Internal Catalogue app Reporting App Bob running random SQL queries The Enterprise Database ™
  • 11.
  • 12. Many issues • Evolution is hard • Testing is hard • Versioning / collaboration is hard • Performance is not great
  • 13. the “solution” …. • Team of 50 DBAs • The “database” committee • The “database” change process • The “meta-database” • Db replication • Governance Technical solutions … to solve technical issues … introduced because of technical decisions … with no value to the users = Accidental complexity
  • 14.
  • 15. Moving away from database-driven • Persistence is an implementation detail • Focus on customer value Relational DB, Document DB, Key-Value store, file … Who cares ? Business > Tech
  • 17. Bringing the logic back to the code • No more Stored Procedures • ORM (Entity Framework in that case) • Data-access code + Entities* generated from database * Not quite
  • 18.
  • 19.
  • 20. Status That’s better ! • No more business logic in the DB • Quite readable Still a bit messy: • Not testable • Hard coupling DATA BUSINESS LOGIC
  • 22. DATA BUSINESS LOGIC Better layering Services Repositories + Unit of Work Abstract away details of how data is accessed Orchestrate data-flow for a given use-case
  • 25. Status Quite an improvement • Decoupled • Testable • Easy to know where functionality should live • It worked fine initially But … wait a minute …
  • 26. Object graphs When loading an Order from DB …what else should I load ? - All the relationships ? - Some of them, and leave some unpopulated (null) ? - Some of them, and use lazy- loading ? define Aggregates Deliberately delimit clusters of objects that live together and are loaded/stored together. … keep them as small as possible
  • 27. Object graphs identify the Aggregate Root The unique entry point to the graph Dependencies go only in one direction Repositories return Aggregates through their root
  • 28. More smells … Transaction Script Anemic Domain Model
  • 29. Fighting the Anemic Domain Model • Do not expose setters • Do expose only the Aggregate Root • Do enforce invariants (guard clauses) • Do mutations only through methods • Use intent-revealing names (no Update(…) methods) Make invalid states impossible to represent
  • 30. Transaction Script -> Application Service 1. Load aggregate root from repository 2. Mutate by invoking methods 3. Save to DB
  • 31. Methods on Domain Entities Intent-revealing name Make forbidden state impossible Avoid primitive types
  • 32. Status Even better • Decoupled • Testable • Easy to know where functionality should live • Explicit models and methods • Clean encapsulation • Meaningful names PRESENTATION DATA Application Services Repositories Aggregates
  • 33. What about views ? We defined • Small aggregates • Repositories targeting only Aggregate Roots • Transactional consistency • Repositories hiding data-access For views / reports we need • JOINs across many tables • Small ad-hoc queries on some tables • No transactions • Access to raw data / perf Different needs require different tools
  • 34. Separating Reads and Writes • Commands vs Queries • Write Model vs Read Model CQS (Command Query Separation) CQRS (Command Query Responsibility Segregation) Aggregates View-specific projections As big or small as needed
  • 35. WRITE READ Commands Application Service Repository Commands Commands 1. Load aggregate from repository 2. Validate / mutate 3. Save changes Direct access to the data Queries QueriesQueries Query Handler * * Maybe same as primary, maybe totally different
  • 36. Expose only Aggregates Write Model Read Model Allow edits Read-only Expose projections, DTOs tailored for the view
  • 37. Status Good enough for now ☺ • Decoupled • Testable • Easy to know where functionality should live • Explicit models and methods • Clean encapsulation • Meaningful names • Correct writes • Fast Reads
  • 38. Take aways • Smoothly introduce DDD concepts • Failing is learning • Watch out for smells • Continuously improve • The right tool for the right job • Context is king
  • 39. Going further Some important concepts I left out : • Value Objects • Bounded Contexts • Ubiquitous Language • Domain Events • Context Mapping • …
  • 40. Thanks for listening ! Questions ? Thibaud Desodt - @tsimbalar