SlideShare a Scribd company logo
1 of 55
Download to read offline
Domain Driven Design 101,[object Object]
Domain Driven Design 101
Agenda,[object Object],Why,[object Object],Building blocks,[object Object],Repositories, entities, specifications etc,[object Object],Putting it to practice,[object Object],Dependency injection,[object Object],Persistence,[object Object],Validation,[object Object],Architecture,[object Object],Challenges,[object Object],When not to use DDD,[object Object],Resources,[object Object]
Software is complicated,[object Object]
We solve complexity in software by distilling our problems,[object Object]
publicboolCanBook(Cargocargo, Voyagevoyage),[object Object],{,[object Object],doublemaxBooking = voyage.Capacity * 1.1;,[object Object],if (voyage.BookedCargoSize + cargo.Size > maxBooking),[object Object],returnfalse;,[object Object], ,[object Object],    ...,[object Object],},[object Object],publicboolCanBook(Cargocargo, Voyagevoyage),[object Object],{,[object Object],if (!overbookingPolicy.IsAllowed(cargo, voyage)),[object Object],returnfalse;,[object Object], ,[object Object],    ...,[object Object],},[object Object],DDD is about making concepts explicit,[object Object]
Domain Model,[object Object]
Ubiquitous language,[object Object]
publicinterfaceISapService,[object Object],{,[object Object],doubleGetHourlyRate(intsapId);,[object Object],},[object Object],û,[object Object],A poor abstraction,[object Object],publicinterfaceIPayrollService,[object Object],{,[object Object],doubleGetHourlyRate(Employeeemployee);,[object Object],},[object Object],ü,[object Object],Intention-revealing interfaces,[object Object]
publicclassEmployee,[object Object],{,[object Object],voidApplyForLeave(DateTime start,,[object Object],DateTime end,,[object Object],ILeaveService leaves),[object Object],    {,[object Object],        ...,[object Object],    },[object Object],},[object Object]
Domain Expert,[object Object]
Entities,[object Object]
Value Types,[object Object]
publicclassEmployee : IEquatable<Employee>,[object Object],{,[object Object],publicbool Equals(Employee other),[object Object],    {,[object Object],returnthis.Id.Equals(other.Id);,[object Object],    },[object Object],},[object Object],Entities are the same if they have the same identity,[object Object],publicclassPostalAddress : IEquatable<PostalAddress>,[object Object],{,[object Object],publicbool Equals(PostalAddress other),[object Object],    {,[object Object],returnthis.Number.Equals(other.Number),[object Object],            && this.Street.Equals(other.Street),[object Object],            && this.PostCode.Equals(other.PostCode),[object Object],            && this.Country.Equals(other.Country);,[object Object],    },[object Object],},[object Object],Value Types are the same if they have the same value,[object Object]
publicclassColour,[object Object],{,[object Object],publicint Red { get; privateset; },[object Object],publicint Green { get; privateset; },[object Object],publicint Blue { get; privateset; },[object Object], ,[object Object],publicColour(int red, int green, int blue),[object Object],    {,[object Object],this.Red = red;,[object Object],this.Green = green;,[object Object],this.Blue = blue;,[object Object],    },[object Object], ,[object Object],publicColourMixInTo(Colour other),[object Object],    {,[object Object],returnnewColour(,[object Object],Math.Avg(this.Red, other.Red),,[object Object],Math.Avg(this.Green, other.Green), ,[object Object],Math.Avg(this.Blue, other.Blue));,[object Object],    },[object Object],},[object Object],Value Types are immutable,[object Object]
Aggregates,[object Object]
Aggregate root,[object Object],*,[object Object]
Repositories,[object Object]
publicinterfaceIEmployeeRepository,[object Object],{,[object Object],EmployeeGetById(int id);,[object Object],void Add(Employeeemployee);,[object Object],void Remove(Employeeemployee);,[object Object], ,[object Object],IEnumerable<Employee> GetStaffWorkingInRegion(Regionregion);,[object Object],},[object Object],Repositories provide collection semantics and domain queries,[object Object]
Domain Services,[object Object]
publicinterfaceITripService,[object Object],{,[object Object],floatGetDrivingDistanceBetween(Location a, Location b);,[object Object],},[object Object]
Specifications,[object Object]
classGoldCustomerSpecification : ISpecification<Customer>,[object Object],{,[object Object],publicboolIsSatisfiedBy(Customer candidate),[object Object],    {,[object Object],returncandidate.TotalPurchases > 1000.0m;,[object Object],    },[object Object],},[object Object], ,[object Object],if (newGoldCustomerSpecification().IsSatisfiedBy(employee)),[object Object],// apply special discount,[object Object],Specifications encapsulate a single rule,[object Object]
Specifications can be used…,[object Object],to construct objects,[object Object]
var spec = newPizzaSpecification(),[object Object],              .BasedOn(newMargaritaPizzaSpecification()),[object Object],              .WithThickCrust(),[object Object],              .WithSwirl(Sauces.Bbq),[object Object],              .WithExtraCheese();,[object Object], ,[object Object],var pizza = newPizzaFactory().CreatePizzaFrom(spec);,[object Object],Constructing objects according to a specification,[object Object]
Specifications can be used…,[object Object],for querying,[object Object]
publicinterfaceICustomerRepository,[object Object],{,[object Object],IEnumerable<Customer> GetCustomersSatisfying(,[object Object],ISpecification<Customer> spec);,[object Object],},[object Object],vargoldCustomerSpec = newGoldCustomerSpecification();,[object Object], ,[object Object],var customers = this.customerRepository,[object Object],    .GetCustomersSatisfying(goldCustomerSpec);,[object Object],Querying for objects that match some specification,[object Object]
Anticorruption Layer,[object Object]
Your subsystem,[object Object],Anti-corruption layer,[object Object],Other subsystem,[object Object]
Any 3rd party system that I have to integrate with was written by a drunken monkey typing with his feet.,[object Object],Oren Eini aka Ayende,[object Object]
Bounded Context,[object Object]
publicclassLead,[object Object],{,[object Object],publicIEnumerable<Opportunity> Opportunities { get; },[object Object],publicPerson Contact { get; },[object Object],},[object Object],publicclassClient,[object Object],{,[object Object],publicIEnumerable<Invoice> GetOutstandingInvoices();,[object Object],publicAddressBillingAddress { get; },[object Object],publicIEnumerable<Order> PurchaseHistory { get; },[object Object],},[object Object],publicclassCustomer,[object Object],{,[object Object],publicIEnumerable<Ticket> Tickets { get; },[object Object],},[object Object]
Dependency Injection,[object Object]
publicinterfaceINotificationService,[object Object],{,[object Object],void Notify(Employeeemployee, string message);,[object Object],},[object Object],An interface defines the model,[object Object],publicclassEmailNotificationService : INotificationService,[object Object],{,[object Object],    void Notify(Employeeemployee, string message),[object Object],    {,[object Object],var message = newMailMessage(employee.Email, message);,[object Object],this.smtpClient.Send(message);,[object Object],    },[object Object],},[object Object],Far away, a concrete class satisfies it,[object Object]
publicclassLeaveService,[object Object],{,[object Object],privatereadonlyINotificationService notifications;,[object Object], ,[object Object],publicLeaveService(INotificationService notifications),[object Object],    {,[object Object],this.notifications = notifications;,[object Object],    },[object Object], ,[object Object],publicvoidTakeLeave(Employeeemployee, DateTime start,,[object Object],DateTime end),[object Object],    {,[object Object],// do stuff,[object Object], ,[object Object],this.notifications.Notify(employee, "Leave approved.");,[object Object],    },[object Object],},[object Object],Dependencies are injected at runtime,[object Object]
Persistence Ignorance,[object Object]
…ordinary  classes where you focus on the business problem at hand without adding stuff for infrastructure-related reasons… nothing else should be in the Domain Model.,[object Object]
publicclassCustomer,[object Object],{,[object Object],publicint Id { get; privateset; },[object Object],publicstringFirstName { get; set; },[object Object],publicstringLastName { get; set; },[object Object], ,[object Object],publicIEnumerable<Address> Addresses { get; },[object Object],publicIEnumerable<Order> Orders { get; },[object Object], ,[object Object],publicOrderCreateOrder(ShoppingCart cart),[object Object],    {,[object Object],        ...,[object Object],    },[object Object],},[object Object],Plain Old CLR Object (POCO),[object Object]
[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="AdventureWorksLTModel", Name="Customer")],[object Object],    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)],[object Object],    [global::System.Serializable()],[object Object],publicpartialclassCustomer : global::System.Data.Objects.DataClasses.EntityObject,[object Object],    {,[object Object],        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)],[object Object],        [global::System.Runtime.Serialization.DataMemberAttribute()],[object Object],publicintCustomerID,[object Object],        {,[object Object],get,[object Object],            {,[object Object],returnthis._CustomerID;,[object Object],            },[object Object],set,[object Object],            {,[object Object],this.OnCustomerIDChanging(value);,[object Object],this.ReportPropertyChanging("CustomerID");,[object Object],this._CustomerID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);,[object Object],this.ReportPropertyChanged("CustomerID");,[object Object],this.OnCustomerIDChanged();,[object Object],            },[object Object],        },[object Object],privateint _CustomerID;,[object Object],partialvoidOnCustomerIDChanging(int value);,[object Object],partialvoidOnCustomerIDChanged();,[object Object], ,[object Object],This is not a POCO.,[object Object]
Architecture,[object Object]
Traditional Architecture,[object Object],Presentation,[object Object],Business Logic (BLL),[object Object],Infrastructure,[object Object],Data Access (DAL),[object Object]
Onion Architecture,[object Object],User Interface,[object Object],G,[object Object],Application Services,[object Object],M,[object Object],Domain Services,[object Object],Database,[object Object],Domain Model,[object Object],Services,[object Object],File,[object Object],system,[object Object],Infrastructure,[object Object],Tests,[object Object],etc,[object Object]
Onion Architecture,[object Object],EmployeeController,[object Object],User Interface,[object Object],G,[object Object],Application Services,[object Object],M,[object Object],IEmailSender,[object Object],Domain Services,[object Object],Database,[object Object],Domain Model,[object Object],Services,[object Object],File,[object Object],system,[object Object],Employee,,[object Object],IEmployeeRepository,[object Object],Infrastructure,[object Object],Tests,[object Object],SmtpEmailSender,[object Object],etc,[object Object],NHibernateEmployeeRepository,[object Object]
Validation,[object Object]
Validation Examples,[object Object],Input validation,[object Object],Is the first name filled in?,[object Object],Is the e-mail address format valid?,[object Object],Is the first name less than 255 characters long?,[object Object],Is the chosen username available?,[object Object],Is the password strong enough?,[object Object],Is the requested book available, or already out on loan?,[object Object],Is the customer eligible for this policy?,[object Object],Business domain,[object Object]
publicclassPersonRepository : IPersonRepository,[object Object],{,[object Object],publicvoid Save(Person customer),[object Object],    {,[object Object],if (!customer.IsValid()),[object Object],thrownewException(...),[object Object],    },[object Object],},[object Object],validation and persistence anti-patterns,[object Object]
The golden rule for validation:,[object Object],The Domain Model is always ,[object Object],in a valid state,[object Object]
publicclassNewUserFormValidator : AbstractValidator<NewUserForm>,[object Object],{,[object Object],IUsernameAvailabilityServiceusernameAvailabilityService;,[object Object], ,[object Object],publicNewUserFormValidator(),[object Object],    {,[object Object],RuleFor(f => f.Email).EmailAddress();,[object Object], ,[object Object],RuleFor(f => f.Username).NotEmpty().Length(1, 32),[object Object],            .WithMessage("Username must be between 1 and 32 characters");,[object Object], ,[object Object],RuleFor(f => f.Url).Must(s => Uri.IsWellFormedUriString(s)),[object Object],            .Unless(f => String.IsNullOrEmpty(f.Url)),[object Object],            .WithMessage("This doesn't look like a valid URL");,[object Object], ,[object Object],RuleFor(f => f.Username),[object Object],            .Must(s => this.usernameAvailabilityService.IsAvailable(s)),[object Object],            .WithMessage("Username is already taken");,[object Object],    },[object Object],},[object Object],separation of validation concerns with FluentValidation,[object Object]
Where validation fits,[object Object],EmployeeController,[object Object],User Interface,[object Object],G,[object Object],Application Services,[object Object],M,[object Object],IEmailSender,[object Object],Domain Services,[object Object],Database,[object Object],Employee,,[object Object],IEmployeeRepository,[object Object],Domain Model,[object Object],Services,[object Object],NewUserForm,,[object Object],NewUserFormValidator,[object Object],IOverdraftLimitPolicy,[object Object],File,[object Object],system,[object Object],Infrastructure,[object Object],Tests,[object Object],SmtpEmailSender,[object Object],IUsernameAvailabilityService,[object Object],etc,[object Object],NHibernateEmployeeRepository,[object Object]
Making Roles Explicit,[object Object]
Challenges,[object Object]
When DDD isn’t appropriate,[object Object]
Benefits,[object Object]
Books,[object Object]
Links,[object Object],Domain Driven Design mailing list,[object Object],http://tech.groups.yahoo.com/group/domaindrivendesign/,[object Object],ALT.NET mailing list,[object Object],http://tech.groups.yahoo.com/group/altdotnet/,[object Object],DDD Step By Step,[object Object],http://dddstepbystep.com/,[object Object],Domain Driven Design Quickly (e-book),[object Object],http://www.infoq.com/minibooks/domain-driven-design-quickly,[object Object]

More Related Content

What's hot

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven developmentDmitry Geyzersky
 
Domain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledDomain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledNicola Costantino
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsAlexander van Trijffel
 
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
 
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
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 
DevDay2017 ESGI Essential DDD
DevDay2017 ESGI Essential DDDDevDay2017 ESGI Essential DDD
DevDay2017 ESGI Essential DDDGregory Boissinot
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichIvan Paulovich
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureCrishantha Nanayakkara
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 

What's hot (20)

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 Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
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 and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
Domain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) DistilledDomain Driven Design (Ultra) Distilled
Domain Driven Design (Ultra) Distilled
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain Models
 
Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
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
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
DevDay2017 ESGI Essential DDD
DevDay2017 ESGI Essential DDDDevDay2017 ESGI Essential DDD
DevDay2017 ESGI Essential DDD
 
DDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan PaulovichDDD Tactical Design with Clean Architecture - Ivan Paulovich
DDD Tactical Design with Clean Architecture - Ivan Paulovich
 
Domain Driven Design
Domain Driven Design Domain Driven Design
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
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 

Viewers also liked

Jivy Group - Saying Goodbye
Jivy Group - Saying GoodbyeJivy Group - Saying Goodbye
Jivy Group - Saying GoodbyeRavit Friedberg
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHPSteve Rhoades
 
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
 
CQRS, der etwas andere Architekturansatz
CQRS, der etwas andere ArchitekturansatzCQRS, der etwas andere Architekturansatz
CQRS, der etwas andere ArchitekturansatzOPEN KNOWLEDGE GmbH
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질Young-Ho Cho
 
DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)beom kyun choi
 

Viewers also liked (11)

Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
Context Mapping In Action
Context Mapping In ActionContext Mapping In Action
Context Mapping In Action
 
Pastsimple4
Pastsimple4Pastsimple4
Pastsimple4
 
Jivy Group - Saying Goodbye
Jivy Group - Saying GoodbyeJivy Group - Saying Goodbye
Jivy Group - Saying Goodbye
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
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
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
CQRS, der etwas andere Architekturansatz
CQRS, der etwas andere ArchitekturansatzCQRS, der etwas andere Architekturansatz
CQRS, der etwas andere Architekturansatz
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질
 
DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)
 

Similar to Domain Driven Design 101

ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationEyal Vardi
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
Domain-Driven Design with SeedStack
Domain-Driven Design with SeedStackDomain-Driven Design with SeedStack
Domain-Driven Design with SeedStackSeedStack
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Dan Wahlin
 
14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns ConcreteQConLondon2008
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + SpringBryan Hsueh
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesOry Segal
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedMarcinStachniuk
 
Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0PhilWinstanley
 
Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Max Pronko
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
So S.O.L.I.D Fu - Designing Better Code
So S.O.L.I.D Fu - Designing Better CodeSo S.O.L.I.D Fu - Designing Better Code
So S.O.L.I.D Fu - Designing Better CodeNeil Crookes
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureNicolas Corrarello
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklum Ukraine
 
Применение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисовПрименение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисовCOMAQA.BY
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And TricksJulie Lerman
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfacesdeimos
 

Similar to Domain Driven Design 101 (20)

ASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 ValidationASP.NET MVC 3.0 Validation
ASP.NET MVC 3.0 Validation
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Domain-Driven Design with SeedStack
Domain-Driven Design with SeedStackDomain-Driven Design with SeedStack
Domain-Driven Design with SeedStack
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
 
14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete14147503 Intentions Interfaces Making Patterns Concrete
14147503 Intentions Interfaces Making Patterns Concrete
 
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Client-side JavaScript Vulnerabilities
Client-side JavaScript VulnerabilitiesClient-side JavaScript Vulnerabilities
Client-side JavaScript Vulnerabilities
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
GraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learnedGraphQL - when REST API is not enough - lessons learned
GraphQL - when REST API is not enough - lessons learned
 
Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0Policy Injection in ASP.NET using Enterprise Library 3.0
Policy Injection in ASP.NET using Enterprise Library 3.0
 
Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2Service Oriented Architecture in Magento 2
Service Oriented Architecture in Magento 2
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
So S.O.L.I.D Fu - Designing Better Code
So S.O.L.I.D Fu - Designing Better CodeSo S.O.L.I.D Fu - Designing Better Code
So S.O.L.I.D Fu - Designing Better Code
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Применение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисовПрименение паттерна Page Object для автоматизации веб сервисов
Применение паттерна Page Object для автоматизации веб сервисов
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
Udi Dahan Intentions And Interfaces
Udi Dahan Intentions And InterfacesUdi Dahan Intentions And Interfaces
Udi Dahan Intentions And Interfaces
 

Recently uploaded

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
 
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
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
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
 
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
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
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
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
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
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 

Recently uploaded (20)

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
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
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
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
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
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
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 )
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
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)
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 

Domain Driven Design 101

  • 1.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.

Editor's Notes

  1. -Complexity =enemy-Creeps in-Affects ability to deliver-Separate concerns-Breaking into smaller units-DDD is about distilling into an explicit model-All in one place-Easier to work with than sprocs/code behind
  2. -Not complicated-Important business concept hidden-Not just anonymous calculation-Overbooking policy-2nd example doesn’t need comments-DDD is about making concepts explicit-As separate objects
  3. -Imagine if you could truly isolate all your business logic-DDD is about creating a model of the domain-Subject area-Not usually related to computers-Usually based on people and business-Abstraction of reality-Important bits-e.g.-Domain model includes data AND behaviour-Isolated layer in your application-Living breathing C#, not UML-Completely free from the tech used to implement it-No database, no XML, no files, no web services, biztalk, sharepoint-No transactions-Just pure domain concepts-No dependencies on anything except itself
  4. -Expressed in-Quite often there is a language wall between clients and developers-They says discontinue a product, you translate it to delete it from the product table
  5. -Say we have an app that has to get an employee’s hourly rate-First example is all about the implementation details-Happens to be stored in SAP at the moment-SAP identifier is an implementation detail-Intention revealing interfaces-Expressed in the ubquitious language
  6. -Doesn’t just apply to nouns, but verbs as well-”An employee applies for leave”-Leaves don’t come outta thin air-So we put a method on employee-Makes roles clear, who does what-Also applies to bidirectional associations
  7. -Someone you talk to when you’re figuring all this stuff out-If you’re doing agile he might join team-Not necessarily technical-I have a picture of a business owner-Can explain not only how, but WHY-BAs not best, just proxy
  8. -Object with a thread of continuity-Lasts the lifetime of an object-Like a person-You can change everything about them: name, address, sex-But over their whole lifetime they’re still the same person-Same with object, entities are the same object for the duration of their lifetime-Implemented with an identifier or ID
  9. -Value types on the other hand-Are identified by their value-E.g. color, addresses, shopping lists
  10. -Cluster of objects -Consistency boundary-Simplifies things massively-Master object called aggregate root
  11. -Cannot hold reference to anything except the root-Can’t access any entity except from the root-Consistency boundary-Save the whole thing-Cascades-Versioning-Locking – coarse grain lock-No longer cherry picking
  12. -Common pattern-When you need something-Where you put things when your application isn’t using themAbstracts away persistence- SQL database- Object relational mappers- Stored procs- Caching- Fetching strategiesOne per aggregate root
  13. -Interfaces are first-class member of the domain-Collection semantics-No CRUD (save/update), just add/remove-ORM dirty tracking, get out of this commit mindset-Only domain queries, not general data access -Search -Reporting (OLAPvs OLTP)
  14. -Behaviour that isn’t logically part of any entity
  15. -Trip service-Again uses UL-TripService, not GoogleMapsWebAPI service
  16. -Encapsulates a single business rule-Tests if an object satisfies the specified criteria-Brings UL into code as an explicit NAMED concept-Promotes DRY-Validation-Creating objects-Querying
  17. -When you order a pizza-Say what toppings, crust-If you think about it-Not a pizza yet
  18. -As business get more of their systems integrated-Becoming more common for writing systems that need to talk to other systems-But each system has it’s own semantics that we don’t want in our abstraction-Anticorruption layer maps external objects to fit our model
  19. -Our nice domain model on the left-Little cohesive objects-Hairy tangled third party system -Its own layer-Internals-Facade or adapter patterns
  20. -Another reason why you should use an anti corruption layer-Quote, an Assumption you should make-Lets you mock out the external system-Swap in an alternative when it goes down, for testing etc-Not just for DDD
  21. -Different definitions in different contexts-E.g. different departments may reuse language differently-SOA people often try to shoehorn them together into one grand unified model of the universe-Not how the business works in real life-DDD Embrace each context’s language and model
  22. -Could smush together-Pretty big and unwieldy-Contradictions around contact-Sales: contact is business development manager-Support: contact is developers-Each is a separate domain model-Separate ubiquitous language-Separate persistence-Anticorruption layers between them
  23. -”Don’t call us, we’ll call you” principle
  24. -All about interfaces-Decouple our code-Depend on the model, not the implementation-Users of INotificationService have no idea
  25. -Instead of calling out-Inversion of control
  26. -In stored-proc based apps changes don’t become official until ‘committed’-The database IS the model-Data model gets built first-And the app is just a thin layer and some validation on top-Require frequent round trips-One foot in the DB at all times-Impossible to unit test-In DDD we recognize relational schemas has different objectives-Performance, normalization, indexing-Not a 1:1 mirror of the domain model-Just an implementation detail-A place to put things when your app isn’t using them-Big shift in thinking-Domain model first, figure out how to map it to a relational schema later-But greatly simplifies things-Opens up unit testing-Lets you write a DB later
  27. -Ultimate goal of object relational mappers-Persistence ignorance-The domain model has no idea about data access or things coming and going-The way we achieve this is with POCOs
  28. -So much crap-This is persistence logic-Does not belong in yourdomain model-Use a proper object relational mapper like NHibernate-That maintain mappings separately in a different layer
  29. -DAL talks to SQL-BLL talks to external systems-Presentation talks to the web-Each layer depends on bits in from the layer underneath-So if you want to add something, first you have to add it in the DAL, then BLL-That’s why we found business logic scattered from one end to the other
  30. -Domain model != view model-The M in MVC-Instead of depending downwards, dependenciesgoes inwards
  31. -255 = persistence validation, done by ORM
  32. -Nieve example of things you dont wanna do-Repository doing CRUD-Validating only before it writes to the DB-self-validating entities (doesn’t work for different contexts)-E.g. Hasn’t chosen an insurance policy yet, but doesn’t make them an invalid cusomter
  33. -Cos when you think about-We don’t validate domain entities-We validate forms and actions people try and submit via the UI-Domain model != view model
  34. -Learning curve-Requires a lot of buy in-Fitting into the landscape-Code-People-conceptual contours, generic subdomains, distributed domain driven design
  35. -DDD is for dealing with complex domains-If you don’t have a complex domain-If you have no behaviour or logic-If your’model’ maps perfectly to a relational DB schema-Clues that you don’t need DDD-If you don’t have access to a domain expert-Use it as a pattern language-Only for OO, e.g. no device drivers
  36. -But if you do-Model that’s much easier to understand-Everything in one place-Ubiquitous language-End up with code that’s almost readable by non-technical domain experts-OO done right-Isolation makes it much easier to unit test-Not dependent on technical details-Much easier to refactor-Not a cure for complexity-Not a golden bullet-Overall it’s about lifting our game-At the end of the day we are craftsmen-People come to us-Expect our code to work for a long time-DDD is about achieving that longterm maintainability
  37. -So where to from here-You really wanna read this book
  38. -Just before you go