A love story starring Symfony and Domain-Driven Design

A love story starring Symfony and Domain-Driven Design

This is the story of how I discovered Domain-Driven Design, what happened when I tried to apply it to a Symfony framework project, and what are the key takeaways.

Talk given at SymfonyCon Amsterdam 2019, unconference

88a681988c6744a099be88084dedb545?s=128

Romaric Drigon

November 22, 2019
Tweet

Transcript

  1. A love story starring Symfony and Domain-Driven Design Romaric Drigon

    @ SymfonyCon Amsterdam, 22/11/2019
  2. @romaricdrigon So,ware engineer @ ASIT VD !

  3. How it started

  4. None
  5. Let's code...

  6. Let's try to code...

  7. What went wrong? 2 pre-requisite for DDD: • an itera)ve

    process is in place • domain experts are available and coopera)ve
  8. Hard fact #1: Most us can't do DDD

  9. Hard fact #2: Most us don't need DDD

  10. S"ll, we can learn a lot from DDD

  11. Ubiquitous language

  12. Write a glossary

  13. Automa'c glossary $metadatas = $this->doctrine->getMetadataFactory()->getAllMetadata(); foreach ($metadatas as $metadata) {

    $fields = []; foreach ($metadata->getFieldNames() as $fieldName) { $property = $metadata->getReflectionClass()->hasProperty($fieldName) ? $metadata->getReflectionClass()->getProperty($fieldName) : null; $fields[$fieldName] = [ 'doc' => $property ? $this->cleanPhpDoc($property->getDocComment()) : null, 'isIdentifier' => $metadata->isIdentifier($fieldName), 'name' => $fieldName, 'isNullable' => $metadata->isNullable($fieldName), 'type' => $metadata->getTypeOfField($fieldName), ]; } $entities[] = [ 'doc' => $this->cleanPhpDoc($metadata->getReflectionClass()->getDocComment()), 'name' => $metadata->getReflectionClass()->getShortName(), 'properties' => $fields, ]; } $doc = $this->twig->render('doc.html.twig', ['entities' => $entities]);
  14. Anemic model vs Rich domain model

  15. Does Symfony love DDD? Doctrine ORM ❤ Messenger ❤ Workflow

    ❤ App structure ⁉ Validator ⁉ Forms !
  16. Tac$cal pa$erns

  17. None
  18. “A pa&ern is not a cookbook. It lets you start

    from a base of experience to develop your solu;on, and it gives you some language to talk about what you are doing.” — Eric Evans, Domain-Driven Design
  19. Final word Read books! You can improve a lot quality

    of your so4ware by improving processes and communica9on around Do not be a DDD groupie
  20. Thank you for your a,en.on h"ps:/ /romaricdrigon.github.io/