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
Introduction to DDD
PPTX
Domain Driven Design(DDD) Presentation
PPTX
Domain Driven Design: Zero to Hero
PDF
Domain driven design and model driven development
PPTX
Domain Driven Design
PPTX
Domain Driven Design 101
PPT
Domain Driven Design Demonstrated
PPT
Domain Driven Design (DDD)
Introduction to DDD
Domain Driven Design(DDD) Presentation
Domain Driven Design: Zero to Hero
Domain driven design and model driven development
Domain Driven Design
Domain Driven Design 101
Domain Driven Design Demonstrated
Domain Driven Design (DDD)

What's hot (20)

PPTX
Applying Domain-Driven Design to craft Rich Domain Models
PPTX
Domain Driven Design Introduction
PPSX
Domain Driven Design
PPTX
Domain Driven Design
PDF
Domain Driven Design
 
PDF
D2 domain driven-design
PDF
Domain Driven Design
PDF
MongoDB Aggregation Framework
PPTX
Domain Driven Design
PDF
A Deep Dive into Spring Application Events
PDF
Clean Architecture Essentials - Stockholm Software Craftsmanship
PDF
Domain Driven Design
PPTX
Implementing DDD with C#
PPTX
Brownfield Domain Driven Design
PPTX
Domain driven design
PPTX
Domain Driven Design - Strategic Patterns and Microservices
PPTX
JPA For Beginner's
PPTX
CQRS and Event Sourcing, An Alternative Architecture for DDD
PDF
Domain Driven Design
PPTX
Docker: From Zero to Hero
Applying Domain-Driven Design to craft Rich Domain Models
Domain Driven Design Introduction
Domain Driven Design
Domain Driven Design
Domain Driven Design
 
D2 domain driven-design
Domain Driven Design
MongoDB Aggregation Framework
Domain Driven Design
A Deep Dive into Spring Application Events
Clean Architecture Essentials - Stockholm Software Craftsmanship
Domain Driven Design
Implementing DDD with C#
Brownfield Domain Driven Design
Domain driven design
Domain Driven Design - Strategic Patterns and Microservices
JPA For Beginner's
CQRS and Event Sourcing, An Alternative Architecture for DDD
Domain Driven Design
Docker: From Zero to Hero
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)
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?
PPTX
Domain Driven Design Quickly
PDF
Principles of microservices velocity
DDD patterns that were not in the book
Architecting iOS Project
Domain-Driven Design (Artur Trosin Product Stream)
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?
Domain Driven Design Quickly
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
2019-Nov: Domain Driven Design (DDD) and when not to use it
PPTX
Schibsted Spain - Day 1 - DDD Course
PDF
Domain Driven Design Big Picture Strategic Patterns
PDF
Lecture3
PPTX
An Introduction to Domain Driven Design in PHP
PDF
Domain Driven Design - Building Blocks
PPTX
Designing microservices part2
PPTX
Design for scale
PPTX
Pros & Cons of Microservices Architecture
PPTX
Implementing DDD Concepts in PHP
PPTX
Introduction to CQRS - command and query responsibility segregation
PDF
Android application development
PPTX
Azure Digital Twins 2.0
PDF
Software Architecture and Architectors: useless VS valuable
PDF
Introduction to Neo4j for the Emirates & Bahrain
PPTX
Why We Need Architects (and Architecture) on Agile Projects
PDF
Xamarin 9/10 San Diego Meetup
PPTX
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
PPTX
Angular Owin Katana TypeScript
Add Some DDD to Your ASP.NET MVC, OK?
2019-Nov: Domain Driven Design (DDD) and when not to use it
Schibsted Spain - Day 1 - DDD Course
Domain Driven Design Big Picture Strategic Patterns
Lecture3
An Introduction to Domain Driven Design in PHP
Domain Driven Design - Building Blocks
Designing microservices part2
Design for scale
Pros & Cons of Microservices Architecture
Implementing DDD Concepts in PHP
Introduction to CQRS - command and query responsibility segregation
Android application development
Azure Digital Twins 2.0
Software Architecture and Architectors: useless VS valuable
Introduction to Neo4j for the Emirates & Bahrain
Why We Need Architects (and Architecture) on Agile Projects
Xamarin 9/10 San Diego Meetup
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Angular Owin Katana TypeScript

More from Steven Smith (20)

PPTX
Clean architecture with asp.net core by Ardalis
PDF
Finding Patterns in the Clouds - Cloud Design Patterns
PPTX
Introducing domain driven design - dogfood con 2018
PPTX
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
PPTX
Introducing Domain Driven Design - codemash
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
Clean architecture with asp.net core by Ardalis
Finding Patterns in the Clouds - Cloud Design Patterns
Introducing domain driven design - dogfood con 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Introducing Domain Driven Design - codemash
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

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administration Chapter 2
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPT
JAVA ppt tutorial basics to learn java programming
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Introduction to Artificial Intelligence
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
Introduction Database Management System for Course Database
medical staffing services at VALiNTRY
System and Network Administration Chapter 2
Which alternative to Crystal Reports is best for small or large businesses.pdf
JAVA ppt tutorial basics to learn java programming
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
2025 Textile ERP Trends: SAP, Odoo & Oracle
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Materi-Enum-and-Record-Data-Type (1).pptx
Softaken Excel to vCard Converter Software.pdf
How Creative Agencies Leverage Project Management Software.pdf
Introduction to Artificial Intelligence
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Upgrade and Innovation Strategies for SAP ERP Customers
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
L1 - Introduction to python Backend.pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
VVF-Customer-Presentation2025-Ver1.9.pptx

Domain-Driven Design with ASP.NET MVC