SlideShare a Scribd company logo
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 ™
From ddd to DDD : My journey from data-driven development to Domain-Driven Design
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
From ddd to DDD : My journey from data-driven development to Domain-Driven Design
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
From ddd to DDD : My journey from data-driven development to Domain-Driven Design
From ddd to DDD : My journey from data-driven development to Domain-Driven Design
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

More Related Content

PDF
Onion (clean) architecture
PPTX
Salesforce administrator training presentation slides
PPTX
Modeling microservices using DDD
PPTX
Integrating with salesforce
PPTX
Onion architecture overview
PDF
Democratizing Data
PPTX
Arquitetura de Software EXPLICADA
PPTX
Solution architecture
Onion (clean) architecture
Salesforce administrator training presentation slides
Modeling microservices using DDD
Integrating with salesforce
Onion architecture overview
Democratizing Data
Arquitetura de Software EXPLICADA
Solution architecture

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

PDF
A3 from sql to orm
PPTX
Lets focus on business value
PPTX
Lets focus on business value
PPTX
Domain oriented development
PPTX
Domain Driven Design
PPTX
Practical domain driven design
PPTX
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
PDF
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
PDF
All the cool kids....
PPTX
A Practical Guide to Domain Driven Design: Presentation Slides
PPTX
Lets focus on business value
PPTX
Entity Framework v1 and v2
PDF
[FREE PDF sample] Programming Entity Framework DbContext 1st Edition Julia Le...
PPT
Domain Driven Design (DDD)
PDF
Domain Driven Design and NoSQL TLV
ODP
Into the domain
PDF
Programming Entity Framework Building Data Centric Apps with the ADO NET Enti...
PPTX
Relational data modeling trends for transactional applications
PPTX
Entity Framework V1 and V2
PDF
Pursuing practices of Domain-Driven Design in PHP
A3 from sql to orm
Lets focus on business value
Lets focus on business value
Domain oriented development
Domain Driven Design
Practical domain driven design
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Enterprise PHP Architecture through Design Patterns and Modularization (Midwe...
All the cool kids....
A Practical Guide to Domain Driven Design: Presentation Slides
Lets focus on business value
Entity Framework v1 and v2
[FREE PDF sample] Programming Entity Framework DbContext 1st Edition Julia Le...
Domain Driven Design (DDD)
Domain Driven Design and NoSQL TLV
Into the domain
Programming Entity Framework Building Data Centric Apps with the ADO NET Enti...
Relational data modeling trends for transactional applications
Entity Framework V1 and V2
Pursuing practices of Domain-Driven Design in PHP
Ad

Recently uploaded (20)

PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
AI in Product Development-omnex systems
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Online Work Permit System for Fast Permit Processing
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
history of c programming in notes for students .pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Digital Strategies for Manufacturing Companies
PPTX
ai tools demonstartion for schools and inter college
ISO 45001 Occupational Health and Safety Management System
AI in Product Development-omnex systems
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Operating system designcfffgfgggggggvggggggggg
Odoo Companies in India – Driving Business Transformation.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Online Work Permit System for Fast Permit Processing
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Odoo POS Development Services by CandidRoot Solutions
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
history of c programming in notes for students .pptx
Upgrade and Innovation Strategies for SAP ERP Customers
Navsoft: AI-Powered Business Solutions & Custom Software Development
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Digital Strategies for Manufacturing Companies
ai tools demonstartion for schools and inter college
Ad

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 ™
  • 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
  • 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
  • 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