SlideShare a Scribd company logo
Domain-Driven Designwith ASP.NET MVC 
Steve Smith 
CTO, Falafel Software 
@ardalis| steve.smith@falafel.com
What is Domain-Driven Design (DDD)?
Domain-Driven Design with ASP.NET MVC
Communication 
•Ubiquitous Language 
•Domain Expert Interaction 
Modeling 
•Core Domain 
•Generic Subdomains 
•Bounded Context 
•Context Map 
•Shared Kernel 
•Anti-Corruption Layer 
Implementation 
•Model-Driven Design 
•Layered Architecture 
•Entities 
•Value Objects 
•Services 
•Factories 
•Aggregates 
•Repositories 
•Domain Events
DDD is BIG 
“The more you know, the more you realize you know nothing.” 
Socrates
DDD Fundamentals Course 
•Over 4 hours of content (demos using MVC + SignalR) 
•http://bit.ly/PS-DDD
DDD Benefits 
•Flexibility 
•Software models customer’s understanding of problem 
•Breaks complexity into manageable pieces 
•Well-organized; easily tested 
•Business logic lives in one place
DDD Drawbacks 
•Time and Effort 
•Learning Curve 
•Overkill without Complexity 
•“Anemic” domain model problem
Communication 
“As software developers, we fail in two ways: we build the thing wrong, or we build the wrong thing.” 
Me
Domain-Driven Design with ASP.NET MVC
Ubiquitous Language 
http://upload.wikimedia.org/wikipedia/commons/2/23/Rosetta_Stone.JPG
Language 
“A project faces serious problems when its language is fractured.” 
Eric Evans
Ubiquitous Language 
•Ubiquitous–adjective. Present, appearing, or found everywhere. 
•Synonyms: pervasive, universal 
•Used within a given Bounded Context 
•Used in code, design documents, and conversations 
--Everywhere
DomainTerms 
Domain Experts 
Problem Domain 
Core Domain 
Sub-Domains
Bounded Contexts 
•Provide Separation of Concerns 
•Limit complexity 
•Should be clearly boundedand separate
Appointment Scheduling 
Billing
Appointment Scheduling 
Billing 
Anti- 
Corruption 
Layer
Model Driven Design 
Not Data-Driven
Layered Architecture 
•Ports and Adapters 
•Hexagonal 
•Onion
Organizing in a Solution
Entities 
“Many objects are not fundamentally defined by their attributes, but rather by a thread of continuity and identity.” 
Eric Evans
Changing Attributes Doesn’t Change Which One We’re Talking About 
ID:1 
•Name: Steve Smith 
•Twitter: @ardalis 
•Favorite Color: Blue 
ID: 1 
•Name: StevenSmith 
•Twitter: @ardalis 
•Favorite Color: Blue 
ID: 1 
•Name: Steven Smith 
•Twitter: @ardalis 
•Favorite Color: Orange
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVC
Value Objects 
•Defined by their attributes 
•Immutable 
•Should have no side effects 
•Examples: strings, addresses, currency
Domain-Driven Design with ASP.NET MVC
Immutable!
Domain Services 
•Not a natural part of an Entity or Value Object 
•Interfacedefined in terms of other model elements 
•Should be stateless(but may have side effects)
Services in Different Layers 
UI Layer 
& Application Layer 
Infrastructure 
Domain 
(“Application Core”) 
Message Sending 
Message Processing 
XML Parsing 
UI Services 
Transfer Between Accounts 
Process Order 
Send Email 
Log to a File
Domain Events 
“Use a Domain Event to capture an occurrence of something that happened in the domain.” 
Vaughn Vernon 
Implementing Domain-Driven Design
Domain Event Tips 
•Consider for cases of “whenthis happens, then…” 
•Or “Notify someone when…” 
•Domain events represent the past 
•They already happened 
•Thus, they should be immutable
Examples of Domain Events 
UserAuthenticated 
Appointment 
Confirmed 
PaymentReceived 
$¢£¥
Designing Domain Events 
•Each Event is a Class 
•Use a common interface (e.g. IDomainEvent) 
•Capture when the event took place 
•Include details 
•What would you need to know to trigger this event again? 
•Include identitiesof any entitiesinvolved 
•Initialize all state in constructor 
•No behavior or side effects –just state
More DDD Topics 
•Aggregates 
•Repositories 
•Factories 
DDD Fundamentals on Pluralsight 
Eric Evans’ DDD Book 
steve.smith@falafel.com
Domain Models and MVC Models 
•UI interacts directly with Domain Model 
•Entities, Value Objects 
•Interfaces, Services 
•Views may work with custom ViewModels 
•Client (HTML/JS) code may use another ViewModelas well
Controllers 
•Keep as small as possible 
•Eliminate business logic 
•Inject all dependencies
Views 
•No logic unless encapsulated in tested helpers 
•No business logic if it can instead be modeled in the domain
SignalR 
•Awesome addition to ASP.NET 
•Great for notifications to multiple users 
•Ties in easily with Domain Events
Solution Structure 
•Core 
•Interfaces 
•Model (Entities, Value Objects) 
•Domain Services 
•Infrastructure 
•DbContext 
•File Access 
•System Clock Access 
•Email services 
•Web 
•MVC Project 
•No direct use of Infrastructure
Demo 
Putting DDD into ASP.NET MVC
Domain-Driven Design with ASP.NET MVC

More Related Content

PPTX
Domain Driven Design(DDD) Presentation
PPT
Domain Driven Design (DDD)
PPTX
Domain Driven Design
PPTX
Domain Driven Design Quickly
PPTX
Domain Driven Design
PPTX
Domain Driven Design Introduction
PPTX
Domain driven design
PPT
Domain Driven Design Demonstrated
Domain Driven Design(DDD) Presentation
Domain Driven Design (DDD)
Domain Driven Design
Domain Driven Design Quickly
Domain Driven Design
Domain Driven Design Introduction
Domain driven design
Domain Driven Design Demonstrated

What's hot (20)

PDF
DevDay2017 ESGI Essential DDD
PPTX
Domain-Driven Design
PPTX
Domain Driven Design - Strategic Patterns and Microservices
PPTX
Introduction to DDD
PDF
Domain Driven Design (Ultra) Distilled
PPSX
Domain Driven Design
PPTX
Applying Domain-Driven Design to craft Rich Domain Models
PDF
Domain Driven Design
PPTX
Domain Driven Design
PDF
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
PPTX
Domain Driven Design
PPTX
Domain driven design
PPTX
A Practical Guide to Domain Driven Design: Presentation Slides
PDF
DDD - 1 - A gentle introduction to Domain Driven Design.pdf
PDF
PDF
Introduction to Domain Driven Design
PDF
DDD - 3 - Domain Driven Design: Event sourcing.pdf
PDF
Domain driven design and model driven development
PDF
Le Domain Driven Design, comment bien démarrer ?
PPTX
Introducing Domain Driven Design - codemash
DevDay2017 ESGI Essential DDD
Domain-Driven Design
Domain Driven Design - Strategic Patterns and Microservices
Introduction to DDD
Domain Driven Design (Ultra) Distilled
Domain Driven Design
Applying Domain-Driven Design to craft Rich Domain Models
Domain Driven Design
Domain Driven Design
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Domain Driven Design
Domain driven design
A Practical Guide to Domain Driven Design: Presentation Slides
DDD - 1 - A gentle introduction to Domain Driven Design.pdf
Introduction to Domain Driven Design
DDD - 3 - Domain Driven Design: Event sourcing.pdf
Domain driven design and model driven development
Le Domain Driven Design, comment bien démarrer ?
Introducing Domain Driven Design - codemash
Ad

Viewers also liked (13)

PDF
DDD patterns that were not in the book
PDF
Architecting iOS Project
PDF
Domain-Driven Design (Artur Trosin Product Stream)
PPTX
Implementing DDD with C#
PDF
Solid principles, Design Patterns, and Domain Driven Design
PDF
Domain-driven design - tactical patterns
PPTX
Automation of functional tests using JMeter Part II (in Polish)
PPTX
Domain Driven Design in the Browser - Cameron Edwards
PPTX
Architecture Principles CodeStock
PDF
Beyond design patterns and principles - writing good OO code
PDF
Go-jek's Go-Food Chatbot
PPTX
Why Domain-Driven Design and Reactive Programming?
PDF
Principles of microservices velocity
DDD patterns that were not in the book
Architecting iOS Project
Domain-Driven Design (Artur Trosin Product Stream)
Implementing DDD with C#
Solid principles, Design Patterns, and Domain Driven Design
Domain-driven design - tactical patterns
Automation of functional tests using JMeter Part II (in Polish)
Domain Driven Design in the Browser - Cameron Edwards
Architecture Principles CodeStock
Beyond design patterns and principles - writing good OO code
Go-jek's Go-Food Chatbot
Why Domain-Driven Design and Reactive Programming?
Principles of microservices velocity
Ad

Similar to Domain-Driven Design with ASP.NET MVC (20)

PDF
Add Some DDD to Your ASP.NET MVC, OK?
PDF
D2 domain driven-design
PPTX
Domain Driven Design
PPTX
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
PPTX
Domain Driven Design
PPTX
Introducing domain driven design - dogfood con 2018
PDF
Elements of DDD with ASP.NET MVC & Entity Framework Code First
ODP
Into the domain
PDF
Introduction to Domain driven design
PDF
Clean architecture with ddd layering in php
PPTX
Schibsted Spain - Day 1 - DDD Course
PDF
Domain Driven Design
PDF
Domain driven design: a gentle introduction
PDF
Domain-Driven Design
PPTX
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
PPTX
Intro to Domain Driven Design
PPTX
DDD Intro
PDF
Beyond MVC: from Model to Domain
PDF
Code & Cannoli - Domain Driven Design
PPTX
Crafted Design - GeeCON 2014
Add Some DDD to Your ASP.NET MVC, OK?
D2 domain driven-design
Domain Driven Design
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Domain Driven Design
Introducing domain driven design - dogfood con 2018
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Into the domain
Introduction to Domain driven design
Clean architecture with ddd layering in php
Schibsted Spain - Day 1 - DDD Course
Domain Driven Design
Domain driven design: a gentle introduction
Domain-Driven Design
Domain Driven Design Belfast Meetup - Overview, Lessons and Examples by Josh ...
Intro to Domain Driven Design
DDD Intro
Beyond MVC: from Model to Domain
Code & Cannoli - Domain Driven Design
Crafted Design - GeeCON 2014

More from Steven Smith (20)

PPTX
Clean architecture with asp.net core by Ardalis
PDF
Finding Patterns in the Clouds - Cloud Design Patterns
PPTX
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
PPTX
Most Useful Design Patterns
PPTX
Improving the Design of Existing Software
PPTX
Introducing ASP.NET Core 2.0
PPTX
Decoupling with Domain Events
PPTX
Improving the Quality of Existing Software
PPTX
Improving the Quality of Existing Software
PPTX
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
PPTX
Improving the Quality of Existing Software - DevIntersection April 2016
PPTX
Breaking Dependencies to Allow Unit Testing
PPTX
Improving the Quality of Existing Software
PPTX
A Whirldwind Tour of ASP.NET 5
PPTX
Domain events
PPTX
My Iraq Experience
PDF
Breaking Dependencies to Allow Unit Testing
PPTX
Improving The Quality of Existing Software
PPTX
Refactoring with SOLID Principles (FalafelCon 2013)
PPTX
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Clean architecture with asp.net core by Ardalis
Finding Patterns in the Clouds - Cloud Design Patterns
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Most Useful Design Patterns
Improving the Design of Existing Software
Introducing ASP.NET Core 2.0
Decoupling with Domain Events
Improving the Quality of Existing Software
Improving the Quality of Existing Software
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Improving the Quality of Existing Software - DevIntersection April 2016
Breaking Dependencies to Allow Unit Testing
Improving the Quality of Existing Software
A Whirldwind Tour of ASP.NET 5
Domain events
My Iraq Experience
Breaking Dependencies to Allow Unit Testing
Improving The Quality of Existing Software
Refactoring with SOLID Principles (FalafelCon 2013)
Common ASP.NET Design Patterns - Telerik India DevCon 2013

Recently uploaded (20)

PPTX
Transform Your Business with a Software ERP System
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PPT
Introduction Database Management System for Course Database
PDF
AI in Product Development-omnex systems
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PDF
System and Network Administraation Chapter 3
PPTX
Presentation of Computer CLASS 2 .pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
DOCX
The Five Best AI Cover Tools in 2025.docx
PPTX
ai tools demonstartion for schools and inter college
Transform Your Business with a Software ERP System
Upgrade and Innovation Strategies for SAP ERP Customers
L1 - Introduction to python Backend.pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
VVF-Customer-Presentation2025-Ver1.9.pptx
ISO 45001 Occupational Health and Safety Management System
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
A REACT POMODORO TIMER WEB APPLICATION.pdf
Materi-Enum-and-Record-Data-Type (1).pptx
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
Introduction Database Management System for Course Database
AI in Product Development-omnex systems
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
System and Network Administraation Chapter 3
Presentation of Computer CLASS 2 .pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
The Five Best AI Cover Tools in 2025.docx
ai tools demonstartion for schools and inter college

Domain-Driven Design with ASP.NET MVC