SlideShare a Scribd company logo
1 of 26
Domain Driven Design
Satish Mittal
VP Engineering
Practo
Motivation
Typical application development:
Requirements from business
Task breakdown
Jump to implementation
DB schema - tables and columns
Fast, we are a Startup!
Problems
1. Your project has the same functionality implemented in the same way or
different in different places?
2. You have more than one object for the same item?
3. You have objects that have properties that are not actually attributes of that
object?
4. You have no or very poor relationship among related items?
5. Looking at your objects it is not possible to understand what actually the
whole application is all about?
Problems
Bottom-up vs Top-down approach
Here-and-now vs big-picture
Do I understand the domain of the application?
Solution
Domain Driven Design (DDD)
Coined by Eric Evans
Wikipedia: Domain-driven design is not a technology or a methodology. DDD
provides a structure of practices and terminology for making design decisions
that focus and accelerate software projects dealing with complicated
domains.
Idea: Focus more on complexities intrinsic to core business domain
Domain
Wikipedia: A sphere of knowledge, influence, or activity. The subject area to
which the user applies a program is the domain of the software
Examples:
E-commerce
Professional network
Advertisement
Healthcare
...
What is a model?
It’s not just diagrams (UML, ER): views of model
Model is the set of concepts that we have chosen to implement in our software
Business differentiator
Pattern: Model-driven design
First build an of domain model that actually represents the problem domain
Then express that in code at all times
Change in domain <-> Change in code
Ubiquitous Language
All stakeholders should speak the same language
Product-developers
Developers-developers
The language must be business language, and not technical details
Language: Entity
A concept that has a unique identity within system
Two entities can only be same if their identity is identical
Typically persisted, mutable, status change
Examples:
Friend in Facebook
Item in shopping cart: SKU
News Article: URL
Language: Value Object
Represents a set of attributes
e.g. doors in a room, items in an order, profile details
Typically it has no unique identity of its own
It should be immutable
In some cases, Value Object might become an entity (when unique identity is
needed to invoke some action)
Example: last N SearchCriteria
Language: Value Object
E.g. money: int, double field in code?
How about various currencies: INR/USD?
Recommendation: Define unique class
Money m1 = new Money("GBP", 10);
Money m2 = new Money("GBP", 20);
Money m3 = m1.add(m2);
Typically immutable
Adding m1 to m2 doesn’t alter m1; returns m3
Language: Value Object
E.g. SocialSecurityNumber
E.g. MobilePhoneNumber
E.g. PatientRegistrationNumber
Perform common validations within each class: range check, syntax, format
Refactor duplicate implementations out of applications
Language: Module
Package or library or namespace
Collection of entities and Value Objects related to a context
Focus on having as much reusable modules amongst applications across
company
Language: Aggregate Roots
Entity relationship types: association, aggregation or composition
An aggregate root (AR) is an entity that composes other entities (as well as its
own Value Object) by composition.
Example:
Consult Question (AR) contains multiple Answers. However any Answer can’t exist without
Question
Aggregated entities are referenced only by the root (may be transitively), and
may not be referenced by any objects outside the aggregate.
Some entities are aggregate roots themselves (single node tree)
Language: Aggregate Roots
Identifying AR allows us to define the logical atomic unit of work
critical section of a transaction
AR is responsible for ensuring that all its child entities are always in consistent
state across operations
Example:
Order (AR) contains OrderItems; all OrderItems must be unique
Referential Integrity across ARs:
Appointment for a slot must be given only if Doctor is available that day
Language: Repository
Domain must be agnostic of persistence (MySQL, ES, Redis, FS..)
Repository is an abstraction over persistence layer
Returns collections of aggregate roots (typically meeting some criteria)
Repository is a domain level concept - represented via Interface
Actual implementations belong to Infrastructure layer
Dependency Injection
Domain Service: Represents core business actions, operations on Domain
Entities; manages business rules
Example: Appointment booking, medicine order
Application Service: Handles cross-cutting concerns like transactions, security
etc.
Infrastructure Service: Underlying tech implementation layer
Example: MySQL, SMS communicator, push notification
Language: Service Types
Language: Service Types
Layered architecture
Spectrum of granularity
Value Object < entity < aggregate < module < bounded context
Language: Bounded Context
BC: The functional boundary within which domain model make sense
Recommendation: Divide large application among multiple BCs
More modular
Separation of different concerns
Helps manage and enhance application in an efficient way
Each BC operates in a semi-autonomous fashion
Each BC owned by separate team: domain expert
Avoid BBOM (Big Ball of Mud): unstructured, duct-tape, sphagetti code
Bounded Context: Relationships
published language: the interacting BCs agree on a common language (e.g.
domain schema) by which they can interact with each other;
open host service: a BC specifies a protocol (e.g. RPC/RESTful web service)
by which any other BC can use its services;
shared kernel: two BCs use a common kernel of code (e.g. a library)
Bounded Context: Relationships
customer/supplier: one BC uses the services of another and is a stakeholder
(customer) of that other BC. As such it can influence the services provided by
that BC;
conformist: one BC uses the services of another but is not a stakeholder to that
other BC. As such it uses "as-is" (conforms to) the protocols or APIs provided
by that BC;
anti-corruption layer: one BC uses the services of another and is not a
stakeholder, but aims to minimize impact from changes in the BC it depends
on by introducing a set of adapters – an anti-corruption layer.
Context Map
DDD recommends to draw Context Map to identify which BC do you depend
upon, and which BC depend upon you
Dependency graph amongst systems, with edges that capture the co-operation
level
Helps understand the inter-dependencies better
Helps streamline upstream model changes
Thanks!

More Related Content

What's hot

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
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignAndriy Buday
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
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
 
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
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven DesignNicolò Pignatelli
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design QuicklyMariam Hakobyan
 
Enterprise Software Architecture styles
Enterprise Software Architecture stylesEnterprise Software Architecture styles
Enterprise Software Architecture stylesAraf Karsh Hamid
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignYoung-Ho Cho
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureCrishantha Nanayakkara
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Domain Driven Design – DDD além da teoria!, por Paulo Victor Gomes
Domain Driven Design – DDD além da teoria!, por Paulo Victor GomesDomain Driven Design – DDD além da teoria!, por Paulo Victor Gomes
Domain Driven Design – DDD além da teoria!, por Paulo Victor GomesiMasters
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLCAbdul Karim
 
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
 

What's hot (20)

Domain Driven Design: Zero to Hero
Domain Driven Design: Zero to HeroDomain Driven Design: Zero to Hero
Domain Driven Design: Zero to Hero
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
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
 
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
 
Brownfield Domain Driven Design
Brownfield Domain Driven DesignBrownfield Domain Driven Design
Brownfield Domain Driven Design
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Enterprise Software Architecture styles
Enterprise Software Architecture stylesEnterprise Software Architecture styles
Enterprise Software Architecture styles
 
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 Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal Architecture
 
Scrum + bdd + ddd
Scrum + bdd + dddScrum + bdd + ddd
Scrum + bdd + ddd
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Domain Driven Design – DDD além da teoria!, por Paulo Victor Gomes
Domain Driven Design – DDD além da teoria!, por Paulo Victor GomesDomain Driven Design – DDD além da teoria!, por Paulo Victor Gomes
Domain Driven Design – DDD além da teoria!, por Paulo Victor Gomes
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
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
 

Viewers also liked

Project Management in Digital Age
Project Management in Digital AgeProject Management in Digital Age
Project Management in Digital AgeMehdi Shamizanjani
 
詹姆士看天下 2017/02/13
詹姆士看天下 2017/02/13詹姆士看天下 2017/02/13
詹姆士看天下 2017/02/13ezfunds
 
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...Maxi Silvestre
 
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~さくらのIoT Platformを使ってみよう ~OSC浜名湖編~
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~法林浩之
 
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6vinhbinh2010
 
Eu coal stress_test_report_2017 WindSolar = More and More Coal (1)
Eu coal stress_test_report_2017  WindSolar = More and More Coal (1)Eu coal stress_test_report_2017  WindSolar = More and More Coal (1)
Eu coal stress_test_report_2017 WindSolar = More and More Coal (1)www.thiiink.com
 
999C1400_De NoraGWSBrochure_Sept15-EMAIL
999C1400_De NoraGWSBrochure_Sept15-EMAIL999C1400_De NoraGWSBrochure_Sept15-EMAIL
999C1400_De NoraGWSBrochure_Sept15-EMAILAlfredo Romanelli
 
Idempotent filter with mule
Idempotent filter with muleIdempotent filter with mule
Idempotent filter with muleSon Nguyen
 
BU On Campus presentation of Apr 19 2011
BU On Campus presentation of Apr 19 2011BU On Campus presentation of Apr 19 2011
BU On Campus presentation of Apr 19 2011Jeff Allar
 
EN2 Characteristics of prophecy 2 of 6
EN2 Characteristics of prophecy 2 of 6EN2 Characteristics of prophecy 2 of 6
EN2 Characteristics of prophecy 2 of 6Learning to Prophesy
 
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)takashi ono
 
Domain-driven design
Domain-driven designDomain-driven design
Domain-driven designKnoldus Inc.
 

Viewers also liked (14)

Server-side Swift
Server-side SwiftServer-side Swift
Server-side Swift
 
Project Management in Digital Age
Project Management in Digital AgeProject Management in Digital Age
Project Management in Digital Age
 
詹姆士看天下 2017/02/13
詹姆士看天下 2017/02/13詹姆士看天下 2017/02/13
詹姆士看天下 2017/02/13
 
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...
Evolución del marketing educativo hasta el Inbound marketing. Marketing and S...
 
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~さくらのIoT Platformを使ってみよう ~OSC浜名湖編~
さくらのIoT Platformを使ってみよう ~OSC浜名湖編~
 
Contextual Theology
Contextual TheologyContextual Theology
Contextual Theology
 
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6
JANUARY 2017 - Pictures of the day - Jan. 1 - Jan. 6
 
Eu coal stress_test_report_2017 WindSolar = More and More Coal (1)
Eu coal stress_test_report_2017  WindSolar = More and More Coal (1)Eu coal stress_test_report_2017  WindSolar = More and More Coal (1)
Eu coal stress_test_report_2017 WindSolar = More and More Coal (1)
 
999C1400_De NoraGWSBrochure_Sept15-EMAIL
999C1400_De NoraGWSBrochure_Sept15-EMAIL999C1400_De NoraGWSBrochure_Sept15-EMAIL
999C1400_De NoraGWSBrochure_Sept15-EMAIL
 
Idempotent filter with mule
Idempotent filter with muleIdempotent filter with mule
Idempotent filter with mule
 
BU On Campus presentation of Apr 19 2011
BU On Campus presentation of Apr 19 2011BU On Campus presentation of Apr 19 2011
BU On Campus presentation of Apr 19 2011
 
EN2 Characteristics of prophecy 2 of 6
EN2 Characteristics of prophecy 2 of 6EN2 Characteristics of prophecy 2 of 6
EN2 Characteristics of prophecy 2 of 6
 
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)
マーケティングオートメーション&Mauticとは(WordBench Nagoya 2017年2月勉強会)
 
Domain-driven design
Domain-driven designDomain-driven design
Domain-driven design
 

Similar to Domain driven design

Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignMuhammad Ali
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignLalit Kale
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being DrivenAntonio Terreno
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSMizanur Sarker
 
Arch CoP - Domain Driven Design.pptx
Arch CoP - Domain Driven Design.pptxArch CoP - Domain Driven Design.pptx
Arch CoP - Domain Driven Design.pptxSanjoy Kumar Roy
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"GlobalLogic Ukraine
 
Domain driven design
Domain driven designDomain driven design
Domain driven designtatyaso
 
The Big Picture - Integrating Buzzwords
The Big Picture - Integrating BuzzwordsThe Big Picture - Integrating Buzzwords
The Big Picture - Integrating BuzzwordsAlessandro Giorgetti
 
Making Inter-operability Visible
Making Inter-operability VisibleMaking Inter-operability Visible
Making Inter-operability Visibleliddy
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven DesignAndré Borgonovo
 
Patterns&Antipatternsof SOA
Patterns&Antipatternsof SOAPatterns&Antipatternsof SOA
Patterns&Antipatternsof SOAMohamed Samy
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .netMarco Parenzan
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introductionAsher Sterkin
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsSteve Speicher
 
Writing good C# code for good cloud applications - Draft Oct 20, 2014
Writing good C# code for good cloud applications - Draft Oct 20, 2014Writing good C# code for good cloud applications - Draft Oct 20, 2014
Writing good C# code for good cloud applications - Draft Oct 20, 2014Marco Parenzan
 

Similar to Domain driven design (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
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being Driven
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
 
DDD
DDDDDD
DDD
 
Arch CoP - Domain Driven Design.pptx
Arch CoP - Domain Driven Design.pptxArch CoP - Domain Driven Design.pptx
Arch CoP - Domain Driven Design.pptx
 
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
Java TechTalk "Spring boot made life easier with Kubernetes and Microservices"
 
DDD eXchange
DDD eXchangeDDD eXchange
DDD eXchange
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
The Big Picture - Integrating Buzzwords
The Big Picture - Integrating BuzzwordsThe Big Picture - Integrating Buzzwords
The Big Picture - Integrating Buzzwords
 
Making Inter-operability Visible
Making Inter-operability VisibleMaking Inter-operability Visible
Making Inter-operability Visible
 
Refreshing Domain Driven Design
Refreshing Domain Driven DesignRefreshing Domain Driven Design
Refreshing Domain Driven Design
 
Patterns&Antipatternsof SOA
Patterns&Antipatternsof SOAPatterns&Antipatternsof SOA
Patterns&Antipatternsof SOA
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 
Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Domain driven design: a gentle introduction
Domain driven design:  a gentle introductionDomain driven design:  a gentle introduction
Domain driven design: a gentle introduction
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC Integrations
 
Writing good C# code for good cloud applications - Draft Oct 20, 2014
Writing good C# code for good cloud applications - Draft Oct 20, 2014Writing good C# code for good cloud applications - Draft Oct 20, 2014
Writing good C# code for good cloud applications - Draft Oct 20, 2014
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Domain driven design

  • 1. Domain Driven Design Satish Mittal VP Engineering Practo
  • 2. Motivation Typical application development: Requirements from business Task breakdown Jump to implementation DB schema - tables and columns Fast, we are a Startup!
  • 3. Problems 1. Your project has the same functionality implemented in the same way or different in different places? 2. You have more than one object for the same item? 3. You have objects that have properties that are not actually attributes of that object? 4. You have no or very poor relationship among related items? 5. Looking at your objects it is not possible to understand what actually the whole application is all about?
  • 4. Problems Bottom-up vs Top-down approach Here-and-now vs big-picture Do I understand the domain of the application?
  • 5. Solution Domain Driven Design (DDD) Coined by Eric Evans Wikipedia: Domain-driven design is not a technology or a methodology. DDD provides a structure of practices and terminology for making design decisions that focus and accelerate software projects dealing with complicated domains. Idea: Focus more on complexities intrinsic to core business domain
  • 6. Domain Wikipedia: A sphere of knowledge, influence, or activity. The subject area to which the user applies a program is the domain of the software Examples: E-commerce Professional network Advertisement Healthcare ...
  • 7. What is a model? It’s not just diagrams (UML, ER): views of model Model is the set of concepts that we have chosen to implement in our software Business differentiator
  • 8. Pattern: Model-driven design First build an of domain model that actually represents the problem domain Then express that in code at all times Change in domain <-> Change in code
  • 9. Ubiquitous Language All stakeholders should speak the same language Product-developers Developers-developers The language must be business language, and not technical details
  • 10. Language: Entity A concept that has a unique identity within system Two entities can only be same if their identity is identical Typically persisted, mutable, status change Examples: Friend in Facebook Item in shopping cart: SKU News Article: URL
  • 11. Language: Value Object Represents a set of attributes e.g. doors in a room, items in an order, profile details Typically it has no unique identity of its own It should be immutable In some cases, Value Object might become an entity (when unique identity is needed to invoke some action) Example: last N SearchCriteria
  • 12. Language: Value Object E.g. money: int, double field in code? How about various currencies: INR/USD? Recommendation: Define unique class Money m1 = new Money("GBP", 10); Money m2 = new Money("GBP", 20); Money m3 = m1.add(m2); Typically immutable Adding m1 to m2 doesn’t alter m1; returns m3
  • 13. Language: Value Object E.g. SocialSecurityNumber E.g. MobilePhoneNumber E.g. PatientRegistrationNumber Perform common validations within each class: range check, syntax, format Refactor duplicate implementations out of applications
  • 14. Language: Module Package or library or namespace Collection of entities and Value Objects related to a context Focus on having as much reusable modules amongst applications across company
  • 15. Language: Aggregate Roots Entity relationship types: association, aggregation or composition An aggregate root (AR) is an entity that composes other entities (as well as its own Value Object) by composition. Example: Consult Question (AR) contains multiple Answers. However any Answer can’t exist without Question Aggregated entities are referenced only by the root (may be transitively), and may not be referenced by any objects outside the aggregate. Some entities are aggregate roots themselves (single node tree)
  • 16. Language: Aggregate Roots Identifying AR allows us to define the logical atomic unit of work critical section of a transaction AR is responsible for ensuring that all its child entities are always in consistent state across operations Example: Order (AR) contains OrderItems; all OrderItems must be unique Referential Integrity across ARs: Appointment for a slot must be given only if Doctor is available that day
  • 17. Language: Repository Domain must be agnostic of persistence (MySQL, ES, Redis, FS..) Repository is an abstraction over persistence layer Returns collections of aggregate roots (typically meeting some criteria) Repository is a domain level concept - represented via Interface Actual implementations belong to Infrastructure layer Dependency Injection
  • 18. Domain Service: Represents core business actions, operations on Domain Entities; manages business rules Example: Appointment booking, medicine order Application Service: Handles cross-cutting concerns like transactions, security etc. Infrastructure Service: Underlying tech implementation layer Example: MySQL, SMS communicator, push notification Language: Service Types
  • 20. Spectrum of granularity Value Object < entity < aggregate < module < bounded context
  • 21. Language: Bounded Context BC: The functional boundary within which domain model make sense Recommendation: Divide large application among multiple BCs More modular Separation of different concerns Helps manage and enhance application in an efficient way Each BC operates in a semi-autonomous fashion Each BC owned by separate team: domain expert Avoid BBOM (Big Ball of Mud): unstructured, duct-tape, sphagetti code
  • 22. Bounded Context: Relationships published language: the interacting BCs agree on a common language (e.g. domain schema) by which they can interact with each other; open host service: a BC specifies a protocol (e.g. RPC/RESTful web service) by which any other BC can use its services; shared kernel: two BCs use a common kernel of code (e.g. a library)
  • 23. Bounded Context: Relationships customer/supplier: one BC uses the services of another and is a stakeholder (customer) of that other BC. As such it can influence the services provided by that BC; conformist: one BC uses the services of another but is not a stakeholder to that other BC. As such it uses "as-is" (conforms to) the protocols or APIs provided by that BC; anti-corruption layer: one BC uses the services of another and is not a stakeholder, but aims to minimize impact from changes in the BC it depends on by introducing a set of adapters – an anti-corruption layer.
  • 24.
  • 25. Context Map DDD recommends to draw Context Map to identify which BC do you depend upon, and which BC depend upon you Dependency graph amongst systems, with edges that capture the co-operation level Helps understand the inter-dependencies better Helps streamline upstream model changes