SlideShare a Scribd company logo
1 of 60
Download to read offline
RENDONS LE DDD AUX DEVS
ARNAUD THIEFAINE & DORRA BARTAGUIZ
1er juin 2023
https://github.com/athiefaine/
theater-reservation-kata
POURQUOI APPRENDRE DDD ?
Parce que c'est trop
stylé !
Parce que je veux
faire comme celles
et ceux qui en
parlent
Pour faire bien sur
mon CV
Parce que c'est
peut-être utile en fin
de compte ?
CE QU’ON REPROCHE AU DDD
Je ne suis pas
architecte donc je
n’ai pas eu
l’opportunité de
creuser
Je n’ai pas accès
aux discussions
stratégiques de
l’organisation
L’organisation et les
équipes sont trop
hermétiques pour
en faire
Ça sert surtout à
faire des
diagrammes bullshit
Ca ne redescend
pas jusqu’au code
DDD
BUZZ WORD ?
QUI SOMMES-NOUS ?
Coach / Formateur
Co-auteur « Software Craft »
Twitter ArnaudThiefaine
Github athiefaine
VP Tech @Arolla
Co-auteure & illustratrice « Software Craft »
Twitter DorraBartaguiz
Github iAmDorra
Arnaud
THIEFAINE
Dorra
BARTAGUIZ
https://www.arolla.fr/training/
DOMAIN DRIVEN DESIGN
20 ans
ENQUÊTE
Connaissez-
vous DDD?
non
5%
oui, mais de
nom
28%
oui,
j'applique
quelques
concepts
42%
oui, je suis à
fond
dedans
25%
Apprécient DDD
~56%
Trouvent difficile à
appliquer
~63%
CE QU’ON REPROCHE AU DDD
Je ne suis pas
architecte donc je
n’ai pas eu
l’opportunité de
creuser
Je n’ai pas accès
aux discussions
stratégiques de
l’organisation
L’organisation et les
équipes sont trop
hermétiques pour
en faire
Ça sert surtout à
faire des
diagrammes bullshit
Ca ne redescend
pas jusqu’au code
SUMMARY
• 1e partie
• Kata de modélisation (Theater Kata)
• Value Object au secours des primitive-obsessions
• Séparation du métier de la technique
• pattern sandwich
• Identification des Bounded Contexts
• 2e partie
• Séparation du métier et de la technique
• archi hexa
• Protéger les invariants (Aggregate, Entity, Value
Object)
• Service & repository
• Découpage en Bounded Contexts
THEATER KATA
Barnabé au Théâtre de Paris
50% VIP
35€ catégorie standard
+50% en premium
THEATER KATA
Barnabé « Le CICD »
THEATER KATA
Éric réserve pour quatre
Sièges côte-à-côte
Carte abonnement
Tickets
Catégorie premium
REVENONS AU CODE
EXTRACT VALUE TYPE
1. Extract method from primitive value
2. Move to a new target class
3. Convert from static to non-static
4. Extract primitive value as field initialized in constructor
5. In constructor, extract parameter for the value
EXTRACT VALUE TYPE OPERATION
1. Wrap the result of operation in value type
2. Extract method from value type expression
3. Wrap each parameter as value type
4. Extract wrapped value types as parameters
5. Convert from static to non-static (this action moves
the method in the value type)
PRICING ARITHMETICS
PRICING ARITHMETICS
SECURE BY DESIGN
Dan
Daniel
Daniel
REVENONS AU CODE
PATTERN SANDWICH
REVENONS AU CODE
IDENTIFICATION DES
DIFFÉRENTS
MÉTIERS/DOMAINES
AKA BOUNDED CONTEXTS
SJƆ & ING Disposition
des sièges
Tarification
Impression
des tickets
Réservations
des places Marketing
Planification des
représentations
SJƆ & ING
Réservations
des places
Disposition
des sièges
Marketing
Planification des
représentations
Tarification
Impression
des tickets
PERSONAE
Barnabé,
actor
Julie,
marketing
Eric, client
Direction
Terminal
SYNONYMES Disposition
des sièges
Tarification
Impression
des tickets
Réservations
des places Marketing
Planification des
représentations
TIPS IDENTIFICATION DES BCS
•“/t/s/ion” sjɔ̃ - “ing”
•Différents personae
•Synonymes
•Termes à sens multiples
LES 3 COMPLEXITÉS DU LOGICIEL
• Essentielle : nature du problème à résoudre
• Intrinsèque au métier
• Obligatoire : l’outillage technique qui supporte la
résolution du problème
• Liée aux contraintes d’exploitation
• Accidentelle : les erreurs de développement
• L’essentiel de la dette technique
Incompressible
Compressible
Suppressible
HEXAGONAL ARCHITECTURE
Not Domain
Domain
Adapters
Ports
API / exposition SPI / infra
Mock infra,
not domain
REVENONS AU CODE
SPÉCIFICATION
• Invariant de domaine de type prédicat
• Valide un objet domaine avec isSatisfiedBy()
• Modélise une règle de gestion
• Configurable
Domain
Specification
REVENONS AU CODE
REPOSITORY
• Collection-oriented
• Manage transaction
• in repo not the service
• Effet de bord
• Injectable
• Ubiquitous language
• pour le nommage
Domain
Repository
EXTRACT REPOSITORY
1. Move to a new target class (suffix Adapter)
2. Convert to instance method
3. Extract interface
4. Pull member up
5. Extract value as field initialized in constructor
6. Type migration of field to use interface
7. In constructor, extract parameter for the value
8. Type migration of parameter to use interface
AGGREGATE
• Identité unique pour la grappe
• Aggregate Root
• Invariant à protéger
• Consistance
• validité
• transactionnelle(save/load)
Domain
Aggregate
REVENONS AU CODE
Allocation
Performance
Id
play
startDate
endDate
performanceNature
Reservation
Topology
Allocation
TheaterSession
titre
startDate
Reservation
PerformanceNature
value
Performance
Id
play
startDate
endDate
performanceNature
Topology
Value object
Pas d’identité
Egalité par valeur
Immuable
Constructeur paramétré
Factory method
Side-effect-free
Entity
Identité
Continuité dans le temps
Domain
Entity
ValueObject
Entity
Identity
Vide /
rempli
Value
object
https://www.amazon.fr/Marque-verres-Party-UNO-VINO-couleurs/dp/B00NXLXFBE/ref=asc_df_B00NXLXFBE?tag=bingshoppin0f-21&linkCode=df0&hvadid=80676722682045&hvnetw=o&hvqmt=e&hvbmt=be&hvdev=c&hvlocint=&hvlocphy=&hvtargid=pla-
4584276297093740&psc=1
REVENONS AU CODE
THEATER TOPOLOGY
Balcony 1
(premium)
Balcony 2
(premium)
Row E
Row F
Row G
Row I
Row J
Row K
Row A
Row B
Row C
Row D
Central zone
(standard)
THEATER TOPOLOGY
Balcony 1
(premium)
Balcony 2
(premium)
Row E
Row F
Row G
Row I
Row J
Row K
Row A
Row B
Row C
Row D
Central zone
(standard)
THEATER TOPOLOGY
Balcony 1
(premium)
Balcony 2
(premium)
Row E
Row F
Row G
Row I
Row J
Row K
Row A
Row B
Row C
Row D
Central zone
(standard)
SEAT ALLOCATION
Row E
Row F
Row G
Row I
Row J
Row K
Row A
Row B
Row C
Row D
REVENONS AU CODE
SERVICE
• Stateless
• Injectable
• Logique métier
• ni dans VO
• ni dans Entity
• Ubiquitous language
• pour le nommage
Domain
Service
Service
Make sure you need a service. […] Using
Services overzealously will usually result in the
negative consequences of creating an Anemic
Domain Model.
- Vaughn Vernon
Implementing Domain-Driven Design
EXTRACT SERVICE
1. Extract method
2. Inline field dependencies (repositories, etc.) as local variables
3. Make method static
4. Move to a new target class (don't suffix Service, use domain name)
5. Convert to instance method
6. Extract dependencies as fields (initialized in constructor) in the new
service
7. Extract parameter for constructor
POUR RÉSUMER
Aggregate
Aggregate
root
Entity
Value object
Service
Repository Composants
(injectables)
Modèle du domaine
(instanciables)
Specification
REVENONS AU CODE
Reservation
Ticketing
Seat
allocation
Allocation
pooling
Billing
Customer account
(subscription)
Pricing
Theater
topology
https://kahoot.it
--- ----
A VOUS DE JOUER !
• Couverture de tests
• Identification des Bounded Contexts
• Refactoring en baby steps
• Extract Value Object, Entities,
• Aggregates, Repositories, Services
• Naming
MERCI

More Related Content

Similar to TalkRendonsDDDauxDevs_AlpesCraft.pdf

Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantHugo Hamon
 
Meet up - qu'on me donne l'envie de Groomer
Meet up - qu'on me donne l'envie de GroomerMeet up - qu'on me donne l'envie de Groomer
Meet up - qu'on me donne l'envie de GroomerAlexandre Quach
 
Pre04 formation-premiere-pro-les-bases-et-perfectionnement
Pre04 formation-premiere-pro-les-bases-et-perfectionnementPre04 formation-premiere-pro-les-bases-et-perfectionnement
Pre04 formation-premiere-pro-les-bases-et-perfectionnementCERTyou Formation
 
Construire une réflexion.
Construire une réflexion.Construire une réflexion.
Construire une réflexion.ツ Thomas Nicot
 
DDD session BrownBagLunch (FR)
DDD session BrownBagLunch (FR)DDD session BrownBagLunch (FR)
DDD session BrownBagLunch (FR)Cyrille Martraire
 
Combien coûte un site WordPress ? - Wordcamp Paris 2014
Combien coûte un site WordPress ? - Wordcamp Paris 2014Combien coûte un site WordPress ? - Wordcamp Paris 2014
Combien coûte un site WordPress ? - Wordcamp Paris 2014Thierry Pigot
 
ASFA - Organisation et Méthodologie du projet COLSA
ASFA - Organisation et Méthodologie du projet COLSAASFA - Organisation et Méthodologie du projet COLSA
ASFA - Organisation et Méthodologie du projet COLSAFrédéric Sagez
 
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...Search Foresight
 
Ma présentation PFE
Ma présentation PFEMa présentation PFE
Ma présentation PFELouati Aicha
 
Web sémantique et Ecommerce
Web sémantique et EcommerceWeb sémantique et Ecommerce
Web sémantique et EcommerceAntidot
 
BDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilitéBDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilitéCARA_Lyon
 
Domain Driven Design - Agile France 2010
Domain Driven Design - Agile France 2010Domain Driven Design - Agile France 2010
Domain Driven Design - Agile France 2010François Wauquier
 
Conception de thèmes WordPress : construire et optimiser son espace de travail
Conception de thèmes WordPress : construire  et optimiser son espace de travailConception de thèmes WordPress : construire  et optimiser son espace de travail
Conception de thèmes WordPress : construire et optimiser son espace de travailFrédérique Game
 
SEO et données structurées / Sébastien Monnier
SEO et données structurées / Sébastien MonnierSEO et données structurées / Sébastien Monnier
SEO et données structurées / Sébastien Monnierpwod
 
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...Vincent Thavonekham-Pro
 
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience Global Azure Bootcamp 2016 - Lyon : DevOps Datascience
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience FactoVia
 
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigos
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigosAgile Tour 2019 - REX AXA France - Event Storming - 3 amigos
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigosEmilie-Anne GUERCH
 
Utiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateformeUtiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateformepprem
 

Similar to TalkRendonsDDDauxDevs_AlpesCraft.pdf (20)

Symfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 PerformantSymfony2 - Un Framework PHP 5 Performant
Symfony2 - Un Framework PHP 5 Performant
 
Meet up - qu'on me donne l'envie de Groomer
Meet up - qu'on me donne l'envie de GroomerMeet up - qu'on me donne l'envie de Groomer
Meet up - qu'on me donne l'envie de Groomer
 
Pre04 formation-premiere-pro-les-bases-et-perfectionnement
Pre04 formation-premiere-pro-les-bases-et-perfectionnementPre04 formation-premiere-pro-les-bases-et-perfectionnement
Pre04 formation-premiere-pro-les-bases-et-perfectionnement
 
Construire une réflexion.
Construire une réflexion.Construire une réflexion.
Construire une réflexion.
 
DDD session BrownBagLunch (FR)
DDD session BrownBagLunch (FR)DDD session BrownBagLunch (FR)
DDD session BrownBagLunch (FR)
 
Combien coûte un site WordPress ? - Wordcamp Paris 2014
Combien coûte un site WordPress ? - Wordcamp Paris 2014Combien coûte un site WordPress ? - Wordcamp Paris 2014
Combien coûte un site WordPress ? - Wordcamp Paris 2014
 
ASFA - Organisation et Méthodologie du projet COLSA
ASFA - Organisation et Méthodologie du projet COLSAASFA - Organisation et Méthodologie du projet COLSA
ASFA - Organisation et Méthodologie du projet COLSA
 
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...
Synodiance > SEO - Réussir votre refonte avec GEMO - E-Commerce Paris 2014 - ...
 
Ma présentation PFE
Ma présentation PFEMa présentation PFE
Ma présentation PFE
 
to Test or not to Test?
to Test or not to Test?to Test or not to Test?
to Test or not to Test?
 
Web sémantique et Ecommerce
Web sémantique et EcommerceWeb sémantique et Ecommerce
Web sémantique et Ecommerce
 
BDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilitéBDD (Behavior Driven Development) - Une voie vers l'agilité
BDD (Behavior Driven Development) - Une voie vers l'agilité
 
Projet carières is
Projet carières isProjet carières is
Projet carières is
 
Domain Driven Design - Agile France 2010
Domain Driven Design - Agile France 2010Domain Driven Design - Agile France 2010
Domain Driven Design - Agile France 2010
 
Conception de thèmes WordPress : construire et optimiser son espace de travail
Conception de thèmes WordPress : construire  et optimiser son espace de travailConception de thèmes WordPress : construire  et optimiser son espace de travail
Conception de thèmes WordPress : construire et optimiser son espace de travail
 
SEO et données structurées / Sébastien Monnier
SEO et données structurées / Sébastien MonnierSEO et données structurées / Sébastien Monnier
SEO et données structurées / Sébastien Monnier
 
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...
Gab2015 Cedric Derue Vincent Thavonekham Approche Devops pour builder une sol...
 
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience Global Azure Bootcamp 2016 - Lyon : DevOps Datascience
Global Azure Bootcamp 2016 - Lyon : DevOps Datascience
 
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigos
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigosAgile Tour 2019 - REX AXA France - Event Storming - 3 amigos
Agile Tour 2019 - REX AXA France - Event Storming - 3 amigos
 
Utiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateformeUtiliser l'EDI pour développer en multiplateforme
Utiliser l'EDI pour développer en multiplateforme
 

TalkRendonsDDDauxDevs_AlpesCraft.pdf