Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Avoiding the mud - Symfony Live London

Ab44158da0498db70754ee8061e69c31?s=47 Richard Miller
September 21, 2013

Avoiding the mud - Symfony Live London

Ab44158da0498db70754ee8061e69c31?s=128

Richard Miller

September 21, 2013
Tweet

Transcript

  1. AVOIDING THE MUD by Richard Miller http://www.flickr.com/photos/burge5000/22568539/

  2. @mr_r_miller http://www.richardmiller.co.uk

  3. http://www.flickr.com/photos/brostad/8583990904

  4. http://www.flickr.com/photos/dominik99/384027019

  5. http://www.flickr.com/photos/jasmeet/2158002974

  6. Bundles For Everything? http://www.flickr.com/photos/jarkel/2288176

  7. Separate Domain Model From Bundles http://www.flickr.com/photos/30666161@N05/3705814710

  8. HumanResourcesBundle

  9. HumanResourcesBundle HumanResources

  10. HumanResourcesBundle HumanResources

  11. http://www.flickr.com/photos/26582481@N08/3040936355 Enough?

  12. Still Tightly Coupled

  13. AbsenceEntity Request Absence Form Cancel Absence Form Approve Absence Form

    Change Absence Type Form
  14. Sensio\HumanResources\Absence\AbsenceEntity: properties: reason: - NotBlank: { groups: [cancellation] } -

    Length: { max: 300, groups: [cancellation] }
  15. AbsenceEntity Request Absence Form Cancel Absence Form Approve Absence Form

    Change Absence Type Form Request Absence Command Cancel Absence Command Approve Absence Command Change Absence Type Command
  16. What About Templates?

  17. AbsenceEntity upcoming .html .twig details .html .twig calendar .html .twig

    unapproved .html .twig
  18. {% if absence.endDate < date() %} past {% else %}

    absence.status {% endif %} getDisplayStatus() AbsenceEntity getEndDate() getStatus()
  19. {% if absence.endDate < date() %} past {% else %}

    absence.status {% endif %} getDisplayStatus() AbsenceEntity getEndDate() getStatus()
  20. {{ absence.displayStatus }} getDisplayStatus() AbsenceEntity getEndDate() getStatus() getDisplayStatus()

  21. {{ absence.displayStatus }} getDisplayStatus() AbsenceEntity getEndDate() getStatus() getDisplayStatus()

  22. AbsenceEntity Request Absence Form Cancel Absence Form Approve Absence Form

    Change Absence Type Form Absence View upcoming .html .twig details .html .twig calendar .html .twig unapproved .html .twig
  23. AbsenceEntity Request Absence Form Cancel Absence Form Approve Absence Form

    Change Absence Type Form Absence View upcoming .html .twig details .html .twig calendar .html .twig unapproved .html .twig getStatus()
  24. Unapproved Absence View Calendar View AbsenceEntity Request Absence Form Cancel

    Absence Form Approve Absence Form Change Absence Type Form Upcoming Absences View Absence Details View upcoming .html .twig details .html .twig calendar .html .twig unapproved .html .twig
  25. SRP

  26. Behaviour Not State

  27. Request Absence Controller Absence Entity setReason($reason) setStatus(AbsenceEntity::CANCELLED) setCancellationDate(new DateTime()) Cancel

    Absence Command getReason()
  28. Request Absence Controller Absence Entity cancel($reason) Cancel Absence Command getReason()

  29. Cancel Absence Command Absence Entity Validate internal consistency Validate user

    input
  30. CancelAbsenceComm andHandler Cancel Absence Command Handler AbsenceEntity cancel($reason) handle($command) Request

    Absence Controller Absence Entity cancel($reason) Cancel Absence Command
  31. Infrastructure?

  32. Absence Repository (Interface) findById($id) findUpcomingByMember($member) findAllByMember($member) Doctrine ORM Absence Repository

    Doctrine ODM Absence Repository Guzzle Client Absence Repository Infrastructure Domain
  33. AbsenceEntity Absence Repository Domain Bundle Service Config Infrastructure Doctrine ORM

    Absence Repository Mapping Config
  34. Absence Repository (Interface) findById($id) findUpcomingByMember($member) findAllByMember($member) add(AbsenceEntity $absence)

  35. Events

  36. OnUpdate Event AbsenceEntity Dispatches

  37. OnUpdate Event AbsenceEntity Dispatches

  38. Absence Cancelled Event Cancel Absence Command Handler Dispatches

  39. Absence Cancelled Event In Memory Listener Immediate Action Place In

    Messaging Queue Listens
  40. Absence Cancelled Event Flush Listener Listens Absence Approved Event Domain

    Infrastructure Listens
  41. Separating Commands From Queries

  42. Command Command Handler Entity Datastore

  43. Datastore View Datastore View Datastore Command Command Handler Entity Event

  44. Datastore View Datastore View Datastore Command Command Handler Entity View

    Template Event
  45. Separating Bundles Horizontally

  46. Non-application Specific Code

  47. HumanResources CustomLoggingBundle HumanResourcesBundle

  48. HumanResourcesBundle HumanResources CustomLoggingBundle CustomLogging CustomLoggingBundle CustomLoggingBundle CustomLogging HumanResourcesBundle

  49. HumanResources CustomLoggingBundle CustomLogging CustomLoggingBundle CustomLoggingBundle CustomLogging If it must! HumanResourcesBundle

  50. HumanResources CustomLoggingBundle CustomLogging CustomLoggingBundle CustomLoggingBundle CustomLogging HumanResourcesBundle

  51. Separating By Context

  52. AbsencePlannerBundle AbsencePlanner CustomLoggingBundle CustomLogging CustomLoggingBundle RecruitmentBundle Recruitment

  53. Message Queue/REST AbsencePlannerBundle AbsencePlanner CustomLoggingBundle CustomLogging CustomLoggingBundle RecruitmentBundle Recruitment

  54. CustomLoggingBundle CustomLogging CustomLoggingBundle RecruitmentBundle Recruitment Off the shelf Package Message

    Queue/REST Message Queue/REST AbsencePlannerBundle AbsencePlanner
  55. Separate Commonality

  56. AbsencePlannerBundle AbsencePlanner RecruitmentBundle Recruitment AbsencePlannerBundle AbsencePlanner CustomLoggingBundle CustomLogging CustomLoggingBundle RecruitmentBundle

    Recruitment User Management
  57. != Staff Member Entity User Entity

  58. AbsencePlannerBundle AbsencePlanner AbsencePlannerBundle AbsencePlanner CustomLoggingBundle CustomLogging CustomLoggingBundle RecruitmentBundle Recruitment UserManagementBundle

  59. Now?

  60. http://www.flickr.com/photos/mtsofan/8313606885

  61. https://github.com/beberlei/litecqrs-php http://behat.org/

  62. http://williamdurand.fr/ http://verraes.net/#blog http://www.whitewashing.de/

  63. QUESTIONS?