Domain Driven Design
What is DDD
• DDD is an approach to building
software with a focus on
the domain.
Clinic System
Patient
Visit
Clinic
Lets Code
Anemic Model
Rich Model
(Entity)
Strategic Design
• Ubiquitous Language
• Bounded context
• Context Maps
Ubiquitous Language
• Ubiquitous language is a model that
acts as a universal language to help
communication between software
developers and domain experts.
• To produce a clear Ubiquitous
Language you will have to understand
more of the business.
Bounded context
• Is a defined part of software where
particular terms, definitions and rules
apply in a consistent way.
• Payment Context
• Ordering Context
• Patient Registration Context
Context Maps
• Context Maps help in
understanding the whole project,
being able to show the
relationships between the
different Bounded Contexts.
Tactical Design
• Entities
• Aggregates
• Value Objects
• Repositories
• Factories
• Services
• Events
Entity
• Is a plain object that has an
identity (ID) and is potentially
mutable
Patient
Clinic
Doctor
Employee
Aggregates (Aggregate root)
• Aggregate root is an entity that
binds together with other
entities
• Actually a part of aggregate
Visit
Medicines
Procedures
Lab tests
Radiations
Value Objects
• Value objects are immutable.
• They have no identity (ID) like we
found in entity.
• Two value objects can be
considered equal if both of them
have the same type and the
same attributes
Email
Address
Money
Address
Repositories
• To deal with the storage
Factories
• A Factory is an object that has
the single responsibility of
creating other objects
Services
• a home for operations that don’t
quite fit into an aggregate root
• Application Services
• Domain Services
Events
• A Domain Event represents
something that has happened in
the domain
• OrderCreated
• OrderDeleted
Further topics
• CQRS
• Event Sourcing
Ref
• https://thedomaindrivendesign.io/what-is-ddd/
• https://www.amazon.com/Hands-Domain-Driven-Design-NET-
ebook/dp/B07C5WSR9B
• https://dzone.com/articles/ddd-part-ii-ddd-building-blocks
• https://culttt.com/2014/12/24/factories-domain-driven-design/

شرح Domain Driven Design بالعربي