Slide 1

Slide 1 text

A love story starring Symfony and Domain-Driven Design Romaric Drigon @ SymfonyCon Amsterdam, 22/11/2019

Slide 2

Slide 2 text

@romaricdrigon So,ware engineer @ ASIT VD !

Slide 3

Slide 3 text

How it started

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Let's code...

Slide 6

Slide 6 text

Let's try to code...

Slide 7

Slide 7 text

What went wrong? 2 pre-requisite for DDD: • an itera)ve process is in place • domain experts are available and coopera)ve

Slide 8

Slide 8 text

Hard fact #1: Most us can't do DDD

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

S"ll, we can learn a lot from DDD

Slide 11

Slide 11 text

Ubiquitous language

Slide 12

Slide 12 text

Write a glossary

Slide 13

Slide 13 text

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]);

Slide 14

Slide 14 text

Anemic model vs Rich domain model

Slide 15

Slide 15 text

Does Symfony love DDD? Doctrine ORM ❤ Messenger ❤ Workflow ❤ App structure ⁉ Validator ⁉ Forms !

Slide 16

Slide 16 text

Tac$cal pa$erns

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

“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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Thank you for your a,en.on h"ps:/ /romaricdrigon.github.io/