Most Ms are stale and tasteless - and that although they are probably the most important ingredient of a tasty MVC implementation. This session is about the underestimated role of the M and how to create meaningful and clean Domain Models using Domain-Driven Design (a practical approach for creating clean apps for complex domains, independent from a specific technology). Bring your own apron.
1. Robert Lemke
The Secret Recipe for a Juicy M
International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
2. Robert Lemke
chief architect of TYPO3 Phoenix and FLOW3
co-founder of the TYPO3 Association
34 years old
lives in Lübeck, Germany
1 wife, 1 daughter, 1 espresso machine
likes drumming
Montag, 11. Oktober 2010
3. = PHP 5.3 Full Stack Application Framework
Montag, 11. Oktober 2010
4. The FLOW3 Experience
Flow [flō] The mental state of operation in which the person is fully immersed in
what he or she is doing by a feeling of energized focus, full involvement, and
success in the process of the activity. Proposed by positive psychologist Mihály
Csíkszentmihályi, the concept has been widely referenced across a variety of fields.
FLOW3 [flō'three] The application framework which takes care of all hassle and lets
you play the fun part.
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
5. DI Dependency Injection DRY
YAA
OOP Object-Oriented Programming
YAGNI
AOP Aspect-Oriented Programming
CoC
MVC Model View Controller
POPO Plain Old PHP Object TDD
DDD Domain-Driven Design
Montag, 11. Oktober 2010
6. Domain-Driven Design
Domain
Desi
g n
lightblue.com
Lorem Ipsum id solum civibus definitionem usu, ex elit contentiones ius. Lorem
his quando facilisis efficiantur cu, delenit laboramus eos id, nec lorem invidunt te.
Suas aliquid consequuntur ne mei, cu qui dicit graeco timeam. Ad assum decore
definitiones ius, has dicat aliquip vocibus te, at per velit viderer legimus. Per no
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
7. Domain: The activity or business of the user
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
8. Goal
To solve real problems
of a real domain
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
9. Domain-Driven Design
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
10. Domain-Driven Design
focus on the domain and domain logic
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
11. Domain-Driven Design
focus on the domain and domain logic
accurately map the domain concepts to software
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
12. Domain-Driven Design
focus on the domain and domain logic
accurately map the domain concepts to software
form a ubiquitous language among the project members
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
14. Ubiquitous language
a common vocabulary:
important prerequisite for successful collaboration
use same words for
discussion class FlagshipStore {
modeling ...
development public function isProfitable() {
return ($this->earnings > ($this->expenses + $this->safetyMarg
documentation }
...
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
15. Layered Architecture
View
Presentation Controller
Application Logic
Domain Domain Model
Data Mapper (Persistence)
Data source Data Source Abstraction
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
21. DDD Building Blocks
Entity Value Object
Aggregate
Repository
Service
Factory
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
22. Entity
Defined by its identity
(instead of its properties)
Examples: Participant, Blog Post
(you probably used artificial keys like a UUID for
identifying entities in a database table)
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
23. Value Object
Defined by its value
Immutable
Green
Examples: Color, Tag Pantone 354c
R: 105 / G: 165 / B: 80
#69A550
#IPC10
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
24. Service
Actions within the domain which can't
be implemted by entities and value objects
alone
Services should be stateless
Example: "Postpone Conference Service"
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
25. Aggregate
Compound of Entities and Value Objects
Entity is Aggregate Root
No direct references to objects inside the
Aggregate from outside
Reduces complexity
Examples: Speaker Profile, Blog Post, Car ...
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
26. Repository
a.k.a. "where you keep things"
connection between clean domain
and dirty data storage
provides query methods for
retrieving domain objects
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
27. The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
28. The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
29. Further Reading
FLOW3 Website
http://flow3.typo3.org
FLOW3 Download
http://flow3.typo3.org/download
git://git.typo3.org/FLOW3/Distributions/Base.git
TYPO3 Forge
http://forge.typo3.org
Further Reading
http://flow3.typo3.org/about/principles/further-reading
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010
30. Questions
Email: robert@typo3.org
Blog: http://robertlemke.de/blog
Twitter: @t3rob
Slides: http://slideshare.net/rlmp
Feedback: http://joind.in/talk/view/2182
The Secret Recipe for a Juicy M International PHP Conference 2010, Mainz
Montag, 11. Oktober 2010