Page 1
Implementing DDD Concepts in PHP
Steve Rhoades
Panasonic Avionics
http://github.com/steverhoades@steverhoadeshttp://linkedin.com/in/steverhoadeshttp://stephenrhoades.com
Aleksey KhudyakovRoave, LLC
http://github.com/Xerkushttp://roave.com
Special Thanks
Marco Pivetta, Roave LLC http://github.com/ocramius
Page 2
Overview• Ubiquitous Language• Bounded Context• Value Object• Entity• Repository• Collection• Mapper• Identity Map• Unit of Work• Services
Page 3
What is Domain Driven Design
Page 4
Collection of principles and patterns that help developers craft elegant systems
Page 5
Ubiquitous Language
Page 6
Allows for precise communication of ideas between stakeholders and developers
Page 7
Developers should speak the language as well as include the language in the code base
Page 10
Keep varying business processes separated
Page 11
Overlapping of business concerns should communicate through services
Page 13
An object that contains attributes but does not have an identity
Page 14
Value Objects are Immutable
Page 16
Don’t forget behaviors!
Page 19
An entity is an object in your application that has an identity.
Page 20
Anemic Entity anti-pattern
Page 21
Look like Value Objects but have identity
Page 26
A segregated interface that utilizes the ubiquitous language to hide the infrastructure layer
Page 27
Storage, Memory, Remote Service
Page 34
Mapper (Data Mapper)
Page 35
Used to pull Entity data from persistence
Page 36
Developers can create custom Data Mappers without affecting the rest of the application
Page 37
• Unit Test• MongoDB• Redis• MySQL• Oracle• Web Services• File System
Page 41
Caches Entities in memory to ensure there is only one instance in memory at any given time
Page 42
Martin FowlerP of EAA
READ THIS!
Page 45
Utilized when the natural processing on an Entity or a Value Object is no longer valid
Page 46
Domain Services should not contain state
Page 48
Application Services and Domain Services are often confused
Page 49
Application Services orchestrate demands from a given use case or workflow
Page 50
Application Services “should not” contain business logic will make calls to Domain and Infrastructure services as well as Entities
Page 51
Helpful to think of an Application Service as a command object
Page 52
Unit of Work(example of Application Service)
Page 53
Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency
- Martin Fowler, P of EAA
Page 55
Further Resources• Domain Driven Design, Eric Evans• Patterns of Enterprise Application Architecture,
Martin Fowler• Applying Domain-Driven Design and Patterns,
Jimmy Nilsson• Implementing Domain Driven Design, Vernon
Vaughn
Page 56
Please Review
https://joind.in/9594