Domain Driven Design
Domain Driven Design
Domain Design
Modeling Context
DDD Conclusion
4
Successful/Famous System
Represents Good Design?
5
Successful/Famous Systems
Represent Great Process?
6
Development Challenges
Is Software Development about
programming?
languages?
technology?
framework?
design?
application domain?
7
Development Challenges
Knowledge
of
Domain
and
Context
Domain Design
Modeling Context
DDD Conclusion
10
What’s Domain?
It's www.?
11
Domain and Developers
Developers like coding, technical stuff
Domain is
hard
unclear
unknown
12
Why's Domain important?
What's the purpose of the software you're building?
Domain Design
Modeling Context
DDD Conclusion
14
What's a model?
An Example?
15
A Model
It's a concept or idea that is represented in some
form or fashion
May be in a diagram
Written code
Textual description
16
Purpose of Model
Model is often tied to database making it hard to
develop and test
17
What’s it not?
Focusing on model does not mean up-front design
What is a Car?
Car manufacturer?
Driver?
Domain Design
Modeling Context
DDD Conclusion
20
Challenges in Modeling
21
Lost Details
Often, details are lost
23
Capture that Model
24
Agenda
Domain Design
Modeling Context
DDD Conclusion
25
What's Domain Driven
Design?
Way of thinking with some reaffirmed set of
priorities
26
Why DDD?
We've got to Understand the Domain
Communication is critical
28
Agenda
Domain Design
Modeling Context
DDD Conclusion
29
Design
Strategic vs. Tactical
Strategic design is
big picture
high granular
implementation agnostic
Validation logic
Calculations
Business Rules
32
Ubiquitous Language
"A language structured around the domain model and
used by all team members to connect all the activities
of the team with the software"
33
Is Ubiquitous Language UML?
It is to communicate
34
Agenda
Domain Design
Modeling Context
DDD Conclusion
35
From Model to Implementation
Modeling is necessary but not sufficient
Discuss-prototype-feedback cycle
36
Signs of Ineffective Modeling
37
Beyond Class Level Cohesion
38
Which of these two
conveys good design?
Why?
39
Layering
40
Examples of Bad Design
UI does business validation
Hard to modify
Application Layer
Application activities, sequencing, workflow logic, but
no business logic or state, ....
Domain Layer
Business objects with state and behavior, ....
Infrastructure Layer
Persistence, Communication, ....
42
Domain Layer
Information
Business rules
State of business
43
Application/Service Layer
44
Anemic Domain Model
Anemic Domain Models tend to look real
Domain Design
Modeling Context
DDD Conclusion
46
Creating a Model
Entities
Value Objects
Service Objects
Modules
47
Entities
These represent information
Identity is unique
Not prudent as some people don't have it, and laws around its use changes
Has no identity
May be immutable
May be shared
49
Entities and Value Objects
name
Person SSN
(Entity)
Address
50
Service Objects
These are behavior that does not belong to entity or value objects
51
Module
52
Domain Objects Life Cycle
We need to deal with
Aggregates
Factories
Repositories
53
Relationships
one-to-one
one-to-many
54
Relationships Information
55
Relationships and Navigation
Which one of these is better?
Car Engine
Bi-directional Navigation: Engine has link to Car
Car Engine
Uni-directional Navigation: Engine has no link back to Car
56
Design of Relationships
Bi-directional Navigation
Lower Coupling
Vehicle
Car Engine
58
Aggregates
Defines object ownership and boundaries
Queries lead to these and other internal objects are traversed from
here
60
Repositories
The layer that deals with persistence
Some technologies (that will remain unnamed ;)) promote, in the name of
May be Generic
Business rules and coarse grain domain objects are often recognized later
Makes it messier
Hard to maintain
Hard to understand
Good separation of concern can help make code expressive and more explicit
63
Continuous Integration
Reality check
64
Agenda
Domain Design
Modeling Context
DDD Conclusion
65
Context
66
Bounded Context
Define the boundaries of the context
Over complication
Unsatisfactory application
67
Context Map
Helps us outline different Bounded Contexts and
relationships between them
68
Patterns for Creating Context Maps
Shared Kernel
High degree of interaction between contexts
Customer-Supplier
Anticorruption Layers
Interaction with legacy or external systems
Open Host Services
69
Shared Kernel
Large projects involved
teams that work on
different contexts
Increased risk
71
Anticorruption Layer
Interaction with external applications
Anticorruption Layer is
73
Separate Ways
74
Agenda
Domain Design
Modeling Context
DDD Conclusion
75
Concepts in DDD
Layered Architecture
Entities
Value Objects
Services
Modules
Aggregates
Factories
Repositories
Context Boundaries
77
References
78
Thank You!
http://www.agiledeveloper.com — download
79