SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
Overview
Domain-DrivenDesign+ Hands-On Workshop
Cyrille Martraire
@cyriux
Passionate
developer
PARIS
Since 1999
@cyriux
Paris Software
Craftsmanship Community
http://www.meetup.com/paris-software-craftsmanship/
TDD
BDD
DDD
Legacy
Executive Summary
Domain-Driven Design :
• Priorité au domaine, devant la technique
• Parler le langage du métier, pour tout le
monde, dans le code et dans les tests
• Le code est le modèle (et vice-versa)
• Mon arme secrète sur mes projets depuis
2005
h"p://www.virtual-­‐genius.com/blog/post/Domain-­‐Driven-­‐Design-­‐Immersion-­‐Course-­‐e28093-­‐Part-­‐5.aspx
Seniors  Developers
h"p://www.thisisio.ie/blog/arDcle/149/hiring_senior_developer
I. Putting the
model to work
II. Building
blocks
(Tactical
DDD)
III. Refactoring
toward
deeper insight
IV. Strategic DDD
I. Putting the
model to work
II. Building
blocks
(Tactical
DDD)
III. Refactoring
toward
deeper insight
IV. Strategic DDD
DDD +BDD +TDD
= VERY GOOD
FRIENDS!
h"p://www.alicia-­‐logic.com/capspages/caps_viewall.asp?Dtleid=16
SouventDénaturé
Sans outillage
spécifique
CQRS: + populaire
Très respecté
UNE  CURIOSITÉ  SINCÈRE  POUR  LE  
MÉTIER
Au  commencement  :
h"p://jnchaintreuil.com/et-­‐si-­‐le-­‐futur-­‐appartenait-­‐aux-­‐curieux/
Investir dans la
connaissance métier
Mini-­‐training  30mn  
bi-­‐hebdo
h"p://www.femmeactuelle.fr/jardin/jardinage-­‐les-­‐conseils/arroser-­‐son-­‐jardin-­‐pendant-­‐les-­‐vacances-­‐00873
Domain Expert
h"p://bakchich-­‐old.staDc.ddz.fr/IMG/jpg_expert-­‐2.jpg
Le langage compte!
• La  modélisaDon  commence  
avec  le  langage
• A"enDons  aux  «  synonymes  »  
et  aux  mots  centraux  du  
méDer
• Poser  des  bonnes  (meilleures)  
quesDons
h"p://journalism.about.com/od/reporDng/tp/Finding-­‐And-­‐Developing-­‐Ideas-­‐For-­‐News-­‐Stories-­‐And-­‐ArDcles.htm
Ubiquitous Language
• Nommer
•Facile à chercher
•Prononçables
•Sans abréviation
• Définir
•Définition partagée
•Comprendre, pas juste un vocabulaire
h"p://scalin.fr/rubrique-­‐technique/glossaire
Invariants
«  Le  marché  des  instruments  dérivés  est  à  
somme  nulle  »
Σ  Cash  Flows  (toutes  les  contreparDes)  =  0
Bounded Contexts
Il  n’est  pas  possible  de  convenir  du  sens  précis  des  
mots  uDlisés  par  un  grand  nombre  de  personnes.
Il  faut  accepter  ce  fait,  et  donc  définir  dans  quel  
contexte  un  langage  est  clairement  défini  sans  
ambiguité.
Bounded Contexts
→ Context Game
En gros
• DDD  :  façon  d’aborder  les  
problèmes  +  soluDons
•Focus  sur  le  méDer
•Focus  sur  un  langage  
méDer  omniprésent
•Focus  sur  le  core  domain
In practice (code)
25
Modeling
26
*NOT* UML/MDA!
h"p://depinfo.u-­‐cergy.fr/projets/close2u/fr/tag/uml/
No Translation:
Code == Model
• Ubiquitous  Langage  dans  le  code
• Noms  de  classes  &  interfaces
• Noms  de  méthodes
• Code  lisible  en  prose  autant  que  possible
•≥  80%  noms  de  classes  &  méthodes  
lisibles  par  le  méDer
Signal to Noise ratio
http://www.flickr.com/photos/28471130@N07/2666802097
Signal to Noise Ratio
• SNR ≥ 80 %
• Signal: CashFlow, CashFlowSequence,
CashFlowEngine, FinancialProduct,
BankHolidays, ReferenceData
• Noise: CashFlowBuilder,
CompositeEngine, ProductFactory,
BankHolidaysDecorator, SMTPImpl
Tactical Patterns
(to help write code with
more signal less noise)
31
null
Code concentré en métier
• 100%  méDer  (ou  presque)
• No  framework  polluDon
• Spring,  Hibernate,  logger
• No  javax.*
• No  SQL
• Only
h"p://code.google.com/p/guava-­‐libraries/
Dans  le  
modèle  de  
domaine
[Object Calisthenics]
1. Wrap all primitives and strings
2. Use only one dot per line
3. Don’t abbreviate
4. Keep all classes small
5. Don’t use any classes with more than
two instance variables
6. Use first-class collections
7. Don’t use any getters/setters/
properties
3 kinds of classes:
Value Objects
Entities
Services
34
Value Object
• No  parDcular  idenDty,  equality  by  value
• Immutable
• Constructor  /  StaDc  Creator  /  Factory  method
• FP-­‐Style
• Side-­‐effect-­‐free
Mon  choix  par  
défaut,  sauf  si  
vraiment  pas  
possible  !
Equality  by  value
Value Object
«  DayShiX  by  -­‐2  
WORKING  days  »
No  ge^er/se^er
Immutable
Enum
Behavior!
• Fowler  pa"erns:  QuanDty,  Range,  
Money...
• Functional programming style
• Immutable, clone to mutate
• Capture values (snapshot)
• History object of every version
• Builder to help creation
• Common example:
• String & StringBuilder
Value Object
Défini  par  une  
idenDté  arbitraire
NoDon  de  conDnuité  
dans  le  temps
Entities
Une  collecDon  d’objets  liés  
qui  partagent  une  
cohérence  ensembles,  
avec  une  enDté  racine  pour  
l’idenDté  :  Aggregate  Root
Aggregates
h"p://www.boitearece"es.com/fruits_legumes/raisin-­‐text.htm
Ni  une  valeur  ni  une  enDté
Services
h"p://www.andeka.co.cc/2011/07/postbox-­‐251.html
Persistence Ignorance
• You  can  defer  decisions  about  persistence  (and  
UI)  for  a  long  Dme
• Your  domain  must  NOT  care!
Un  service,  la  facade  coté  
méDer  d’un  stockage
Sans  jamais  parler  de  base  
de  données.
Repository
h"p://www.andeka.co.cc/2011/07/postbox-­‐251.html
Repository
h"p://www.andeka.co.cc/2011/07/postbox-­‐251.html
Interface
DAO
A  predicate  to  filter  
something
Specification
boolean isSatisfied(...);
Hexagonal Architecture
h"p://pragprog.com/magazines/2009-­‐12/going-­‐naked
Depends  on  
nothing
Now for some
practice
Context Game
Context Game
DDD
Context Game
[préchauffe]
“What's your ideal <kitten>?”
•Grand-mère: doux,
affectueux
•Agent d’entretien: propre,
ne perd pas de poils
Context Game
“What's your ideal <customer>?”
•Sales:
•Shipping:
•Marketing:
•Billing:
•Support:
•Billed customer assistance:
Context Game
“What's your ideal <customer>?”
•Sales: Impulse buyer, lots of money, lots of
needs
•Shipping: Lives nearby, always at home
•Marketing: Very gullible
•Billing: Very solvable, pays in advance cash
•Support: Very clever, never needs any help
•Billed customer assistance: Very stupid, can’t
manage to do anything without help
Different perspectives
MY customer is not the same as YOUR customer
“Describe what you need to represent
customer in your context”
•data
•queries
•stats
•behaviors
Let’s analyze further
“At Amazon, what a book is for you?”
•Catalog: Picture, title, authors, rating, format
(ebook or paper), category
•Recommandation: List of books often
bought together with it
•Shipping: Dimensions, weight, international
restrictions due to content
•Shopping cart: Price, discount eligible
•Customer review: List of (rating, review,
review rating)
•Book Search: title, isbn, authors
•Search Inside!: full-text content, copyright-
dealing policy
Conflicting aspects
suggest several contexts
“I don’t need all these data
to do that, I just need these
3 fields”
Several contexts =
opportunities
Simplify: Isolated bounded contexts Vs Union of all in one universal
do-it-all object
Partitioning: Full-Stack Autonomous Components (screen mashup)
Vs. Bounded Contexts in domain layer only; CQRS
Partitioning: teams, work in parallel; scalability; no cross context
Tx, EC
Merci !
h"p://cathy313.centerblog.net/539-­‐bisounours
Merci!

Weitere ähnliche Inhalte

Andere mochten auch

S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
Python Meetup
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for Python
Timo Stollenwerk
 
Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
Samir Talwar
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
Craig Kerstiens
 

Andere mochten auch (20)

From legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsFrom legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting steps
 
Tom and jef’s awesome modellathon
Tom and jef’s awesome modellathonTom and jef’s awesome modellathon
Tom and jef’s awesome modellathon
 
Documentation avoidance for developers
Documentation avoidance for developersDocumentation avoidance for developers
Documentation avoidance for developers
 
Selling ddd
Selling dddSelling ddd
Selling ddd
 
How to write maintainable code
How to write maintainable codeHow to write maintainable code
How to write maintainable code
 
Death to project documentation with eXtreme Programming
Death to project documentation with eXtreme ProgrammingDeath to project documentation with eXtreme Programming
Death to project documentation with eXtreme Programming
 
Driven Development - Closing the Loop on Scrum
Driven Development - Closing the Loop on ScrumDriven Development - Closing the Loop on Scrum
Driven Development - Closing the Loop on Scrum
 
Sofware Fora de Séria 2016 - Implementando realtime no frontend
Sofware Fora de Séria 2016 - Implementando realtime no frontendSofware Fora de Séria 2016 - Implementando realtime no frontend
Sofware Fora de Séria 2016 - Implementando realtime no frontend
 
Package and distribute your Python code
Package and distribute your Python codePackage and distribute your Python code
Package and distribute your Python code
 
From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)
 
S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
S.O.L.I.D. - Павел Кохан, Python Meetup 26.09.2014
 
ZCA: A component architecture for Python
ZCA: A component architecture for PythonZCA: A component architecture for Python
ZCA: A component architecture for Python
 
Como DDD e Strategic Design estão nos ajudando a modernizar um Legado
Como DDD e Strategic Design estão nos ajudando a modernizar um LegadoComo DDD e Strategic Design estão nos ajudando a modernizar um Legado
Como DDD e Strategic Design estão nos ajudando a modernizar um Legado
 
Organise a Code Dojo!
Organise a Code Dojo!Organise a Code Dojo!
Organise a Code Dojo!
 
Hexagonal Design in Django
Hexagonal Design in DjangoHexagonal Design in Django
Hexagonal Design in Django
 
Simplifying your design with higher-order functions
Simplifying your design with higher-order functionsSimplifying your design with higher-order functions
Simplifying your design with higher-order functions
 
Evolving legacy to microservices and ddd
Evolving legacy to microservices and dddEvolving legacy to microservices and ddd
Evolving legacy to microservices and ddd
 
Python SOLID
Python SOLIDPython SOLID
Python SOLID
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
 
How to write good comments
How to write good commentsHow to write good comments
How to write good comments
 

Ähnlich wie DDD session BrownBagLunch (FR)

20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyon
Clement Bouillier
 
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
ENSIBS
 
Aspectize mdday2010
Aspectize mdday2010Aspectize mdday2010
Aspectize mdday2010
MD DAY
 
Industrialiser la gestion des fichiers multimedia #dcparis13
Industrialiser la gestion des fichiers multimedia #dcparis13Industrialiser la gestion des fichiers multimedia #dcparis13
Industrialiser la gestion des fichiers multimedia #dcparis13
Aurelien Navarre
 

Ähnlich wie DDD session BrownBagLunch (FR) (20)

20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyon
 
Réutilisation de code entre windows 8 et windows phone 8
Réutilisation de code entre windows 8 et windows phone 8Réutilisation de code entre windows 8 et windows phone 8
Réutilisation de code entre windows 8 et windows phone 8
 
Keynote drupagora 2015 7
Keynote drupagora 2015 7Keynote drupagora 2015 7
Keynote drupagora 2015 7
 
Agile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agileAgile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agile
 
AT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet AgileAT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet Agile
 
Drupagora 2013 : Drupal8 et Symfony2, quel impact ?
Drupagora 2013 : Drupal8 et Symfony2, quel impact ?Drupagora 2013 : Drupal8 et Symfony2, quel impact ?
Drupagora 2013 : Drupal8 et Symfony2, quel impact ?
 
Les défis d’une application mobile multi-périphériques avec HTML5
Les défis d’une application mobile multi-périphériques avec HTML5Les défis d’une application mobile multi-périphériques avec HTML5
Les défis d’une application mobile multi-périphériques avec HTML5
 
La Meta-programmation
La Meta-programmation La Meta-programmation
La Meta-programmation
 
Présentation de CoreTechnologie
Présentation de CoreTechnologiePrésentation de CoreTechnologie
Présentation de CoreTechnologie
 
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
Agile Tour Paris 2014 : Ma stack d'outils Agiles, tout un programme !, Cedric...
 
10 tips pour améliorer les performances de vos applications Windows 8
10 tips pour améliorer les performances de vos applications Windows 810 tips pour améliorer les performances de vos applications Windows 8
10 tips pour améliorer les performances de vos applications Windows 8
 
HTML5 & SilverLight 5
HTML5 & SilverLight 5HTML5 & SilverLight 5
HTML5 & SilverLight 5
 
Mockito - Design + tests par Brice Duteil
Mockito - Design + tests par Brice DuteilMockito - Design + tests par Brice Duteil
Mockito - Design + tests par Brice Duteil
 
Aspectize mdday2010
Aspectize mdday2010Aspectize mdday2010
Aspectize mdday2010
 
Développer des applications iOS et Android avec c# grâce à Xamarin par Cyril ...
Développer des applications iOS et Android avec c# grâce à Xamarin par Cyril ...Développer des applications iOS et Android avec c# grâce à Xamarin par Cyril ...
Développer des applications iOS et Android avec c# grâce à Xamarin par Cyril ...
 
Domain_Driven_Design
Domain_Driven_DesignDomain_Driven_Design
Domain_Driven_Design
 
.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotique.NET Microframework: du code, de l&rsquo;électronique, de la robotique
.NET Microframework: du code, de l&rsquo;électronique, de la robotique
 
Les nouvelles architectures Skype for Business
Les nouvelles architectures Skype for BusinessLes nouvelles architectures Skype for Business
Les nouvelles architectures Skype for Business
 
Industrialiser la gestion des fichiers multimedia #dcparis13
Industrialiser la gestion des fichiers multimedia #dcparis13Industrialiser la gestion des fichiers multimedia #dcparis13
Industrialiser la gestion des fichiers multimedia #dcparis13
 
Toutes les raisons d'adopter MongoDB
Toutes les raisons d'adopter MongoDBToutes les raisons d'adopter MongoDB
Toutes les raisons d'adopter MongoDB
 

Mehr von Cyrille Martraire

Mehr von Cyrille Martraire (15)

Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)
Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)
Domain modeling for Digital Transformations (FlowCon Paris 2019 edition)
 
Sunny Tech 2019 - Craft Forever
Sunny Tech 2019 - Craft ForeverSunny Tech 2019 - Craft Forever
Sunny Tech 2019 - Craft Forever
 
Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...
Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...
Hexagonal at Scale, with DDD and microservices! - Voxxed Days microservices 2...
 
Bounded Context - DDD Europe Foundation Track
Bounded Context - DDD Europe Foundation TrackBounded Context - DDD Europe Foundation Track
Bounded Context - DDD Europe Foundation Track
 
Domain Modeling towards First Principles
Domain Modeling towards First PrinciplesDomain Modeling towards First Principles
Domain Modeling towards First Principles
 
DDD beyond the infamous repository pattern - GeeCon Prague 2018
DDD beyond the infamous repository pattern - GeeCon Prague 2018DDD beyond the infamous repository pattern - GeeCon Prague 2018
DDD beyond the infamous repository pattern - GeeCon Prague 2018
 
DDD for real
DDD for realDDD for real
DDD for real
 
Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...
Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...
Les effets inattendus du passage en Features Teams à grande échelle -ScrumDay...
 
Refactor your Specs - 2017 Edition
Refactor your Specs - 2017 EditionRefactor your Specs - 2017 Edition
Refactor your Specs - 2017 Edition
 
Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...
Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...
Interviewing Domain Experts - Heuristics From the Trenches (DDD Europe 2016 M...
 
Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...
Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...
Living Documentation (NCrafts Paris 2015, DDDx London 2015, BDX.io 2015, Code...
 
Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014
 
Ur Domain Haz Monoids
Ur Domain Haz MonoidsUr Domain Haz Monoids
Ur Domain Haz Monoids
 
Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013Refactor your specs! Øredev 2013
Refactor your specs! Øredev 2013
 
I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"I T.A.K.E. talk: "When DDD meets FP, good things happen"
I T.A.K.E. talk: "When DDD meets FP, good things happen"
 

DDD session BrownBagLunch (FR)