The Secret Recipe of a Juicy M

1,561 views

Published on

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.

  • Be the first to comment

  • Be the first to like this

The Secret Recipe of a Juicy M

  1. 1. Robert Lemke The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  2. 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 drummingMontag, 11. Oktober 2010
  3. 3. = PHP 5.3 Full Stack Application FrameworkMontag, 11. Oktober 2010
  4. 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, MainzMontag, 11. Oktober 2010
  5. 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 DesignMontag, 11. Oktober 2010
  6. 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, MainzMontag, 11. Oktober 2010
  7. 7. Domain: The activity or business of the user The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  8. 8. Goal To solve real problems of a real domain The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  9. 9. Domain-Driven Design The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  10. 10. Domain-Driven Design focus on the domain and domain logic The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  11. 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, MainzMontag, 11. Oktober 2010
  12. 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, MainzMontag, 11. Oktober 2010
  13. 13. Montag, 11. Oktober 2010
  14. 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, MainzMontag, 11. Oktober 2010
  15. 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, MainzMontag, 11. Oktober 2010
  16. 16. Montag, 11. Oktober 2010
  17. 17. Montag, 11. Oktober 2010
  18. 18. Montag, 11. Oktober 2010
  19. 19. Montag, 11. Oktober 2010
  20. 20. Montag, 11. Oktober 2010
  21. 21. DDD Building Blocks Entity Value Object Aggregate Repository Service Factory The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  22. 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, MainzMontag, 11. Oktober 2010
  23. 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, MainzMontag, 11. Oktober 2010
  24. 24. Service Actions within the domain which cant 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, MainzMontag, 11. Oktober 2010
  25. 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, MainzMontag, 11. Oktober 2010
  26. 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, MainzMontag, 11. Oktober 2010
  27. 27. The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  28. 28. The Secret Recipe for a Juicy M International PHP Conference 2010, MainzMontag, 11. Oktober 2010
  29. 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, MainzMontag, 11. Oktober 2010
  30. 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, MainzMontag, 11. Oktober 2010
  31. 31. Montag, 11. Oktober 2010

×