SlideShare uma empresa Scribd logo
1 de 109
Baixar para ler offline
Ricette
       veloci per
        Domain-
         Driven
        Design



                      dal menù di
                      @ziobrando
venerdì 22 marzo 13
About me
            In the IT field since ZX Spectrum
            Generally in large scale projects (I might be biased)
            Strategic IT Consultant
            Trainer (Avanscoperta & Skills Matter)
            Technical Writer
            Blogger: http://ziobrando.blogspot.com
            Twitter: @ziobrando


           My e-mail: alberto.brandolini@gmail.com


venerdì 22 marzo 13
About me
            Mi piace risolvere problemi
            O scrivere software che li risolva

            Blogger: http://ziobrando.blogspot.com
            Twitter: @ziobrando



           My e-mail: alberto.brandolini@gmail.com


venerdì 22 marzo 13
About me
            In the IT field since ZX Spectrum
            Generally in large scale projects (I might be biased)
            Strategic IT Consultant
            Trainer (Avanscoperta & Skills Matter)
            Technical Writer
            Blogger: http://ziobrando.blogspot.com
            Twitter: @ziobrando


           My e-mail: alberto.brandolini@gmail.com


venerdì 22 marzo 13
Aggregates

                      It is difficult to guarantee the consistency of
                      changes to objects in a model with complex
                      associations. Invariants need to be
                      maintained that apply to closely related
                      groups of objects, not just discrete objects.
                      An AGGREGATE is a cluster of associated
                      objects that we treat as a unit for the purpose of
                      data changes.


venerdì 22 marzo 13
...quale miglior aggregato?




venerdì 22 marzo 13
Customer!

                        Customer




venerdì 22 marzo 13
Customer!

                        <<Entity>>
                        Customer




venerdì 22 marzo 13
Customer!
                      <<Aggregate Root>>
                          <<Entity>>
                          Customer




venerdì 22 marzo 13
Customer!
                        <<Aggregate Root>>
                            <<Entity>>
                            Customer

                      nome
                      cognome




venerdì 22 marzo 13
Customer!
                         <<Aggregate Root>>
                             <<Entity>>
                             Customer
                      nome
                      cognome
                      username
                      emailAddress




venerdì 22 marzo 13
Customer!
                         <<Aggregate Root>>
                             <<Entity>>
                             Customer

                      nome
                      cognome
                      username
                      emailAddress
                      address
                      country
                      language

venerdì 22 marzo 13
Domande?




venerdì 22 marzo 13
Domande?
       - Persistenza?




venerdì 22 marzo 13
Domande?
       - Persistenza?
             - Fa tutto lui! :-)




venerdì 22 marzo 13
Domande?
       - Persistenza?
             - Fa tutto lui! :-)
       - Come gestisco address?


venerdì 22 marzo 13
Domande?
       - Persistenza?
             - Fa tutto lui! :-)
       - Come gestisco address?
       - Dove tengo la password?

venerdì 22 marzo 13
Domande?
       - Persistenza?
             - Fa tutto lui! :-)
       - Come gestisco address?
       - Dove tengo la password?

venerdì 22 marzo 13
Domande?
       - Persistenza?
             - Fa tutto lui! :-)
       - Come gestisco address?
       - Dove tengo la password?

venerdì 22 marzo 13
È un mappazzone!




venerdì 22 marzo 13
Dov’è il
                      comportamento?


venerdì 22 marzo 13
Riproviamo


venerdì 22 marzo 13
Trucco N°1
                                      -
                                    CQRS
                      Command/Query Responsibility Segregation




venerdì 22 marzo 13
!                     Architettura ottimizzata
                          per i comandi




?
venerdì 22 marzo 13
                      Architettura ottimizzata
                           per le letture
Domain Model
                                     Command       Aggregate         Event
                                                                                  Event store
                                                                     Event
                                                                      Event
                                                                                      Event
                           UI                                                          Event


                                         Command         Aggregate
                                                                        Event
    Presentation



                                                                          Event


                                UI


                                                                                           Event


                      UI


                                                                                    Projection

                                       DTO                                               Projection

                           UI
                                                   DTO




                                                                                  Read Model
venerdì 22 marzo 13
Non solo velocità
venerdì 22 marzo 13
Non parleremo di
                         questo...


venerdì 22 marzo 13
Conceptual CQRS

                                           Command      to     Domain Model         raises
                                  issues




                                                                                       Event
                      User

                                           Read Model
         influences                                                                  notified to
                             influences
                                                             updates   Projection
        External
      information




                                  Warning! non è architettura...
venerdì 22 marzo 13
Qui decide l’utente
                                                        Command
                                               issues




                                   User

                                                        Read Model
                      influences          influences



                  External
                information


venerdì 22 marzo 13
Quali informazioni




venerdì 22 marzo 13
User Steps
       -       L’utente decide quali comandi
               invocare sul sistema sulla base
               delle informazioni derivanti
               dalla sua esperienza, e da
               quanto reso disponibile
               dall’applicazione

venerdì 22 marzo 13
Examples?


       - Timesheet entry


venerdì 22 marzo 13
Conceptual CQRS

                                           Command      to     Domain Model         raises
                                  issues




                                                                                       Event
                      User

                                           Read Model
         influences                                                                  notified to
                             influences
                                                             updates   Projection
        External
      information




venerdì 22 marzo 13
Vi ho tolto il DB!




venerdì 22 marzo 13
Piangere
non
servirà a
nulla...



venerdì 22 marzo 13
Conceptual CQRS

                                           Command      to     Domain Model         raises
                                  issues




                                                                                       Event
                      User

                                           Read Model
         influences                                                                  notified to
                             influences
                                                             updates   Projection
        External
      information




venerdì 22 marzo 13
Aggregates

                      It is difficult to guarantee the consistency of
                      changes to objects in a model with complex
                      associations. Invariants need to be
                      maintained that apply to closely related
                      groups of objects, not just discrete objects.
                      An AGGREGATE is a cluster of associated
                      objects that we treat as a unit for the purpose of
                      data changes.


venerdì 22 marzo 13
Aggregate History




venerdì 22 marzo 13
Aggregate History
       - Propagazione




venerdì 22 marzo 13
Aggregate History
       - Propagazione
             -        2004 una generica “comunicazione
                      asincrona”




venerdì 22 marzo 13
Aggregate History
       - Propagazione
             -        2004 una generica “comunicazione
                      asincrona”

             -        2010 ... Domain Events




venerdì 22 marzo 13
Aggregate History
       - Propagazione
             -        2004 una generica “comunicazione
                      asincrona”

             -        2010 ... Domain Events

       - Struttura interna:

venerdì 22 marzo 13
Aggregate History
       - Propagazione
             -        2004 una generica “comunicazione
                      asincrona”

             -        2010 ... Domain Events

       - Struttura interna:
             -        2004: “Don’t fight your frameworks”


venerdì 22 marzo 13
Aggregate History
       - Propagazione
             -        2004 una generica “comunicazione
                      asincrona”

             -        2010 ... Domain Events

       - Struttura interna:
             -        2004: “Don’t fight your frameworks”

             -        ORM / NoSQL / Event Sourcing /
                      Functional...
venerdì 22 marzo 13
Domain Model


            Command     to   Domain Model   raises




                                               Event




venerdì 22 marzo 13
Domain Model


       - Qui è dove è il sistema a
               prendere le decisioni.



venerdì 22 marzo 13
I dati non sono tutti iguali
    Il sistema prenderà una
    decisone basandosi su
    questi dati




  ..l’utente si baserà su
  questi, ed altro...

venerdì 22 marzo 13
Come lo preparo?




venerdì 22 marzo 13
Domain Model


            Command     to   Domain Model   raises




                                               Event




venerdì 22 marzo 13
Outside in



venerdì 22 marzo 13
Non ci guardo
                        dentro...


venerdì 22 marzo 13
...




venerdì 22 marzo 13
...




                      ...ma se devo prendere le
                        informazioni da un’altro
                              aggregato?

venerdì 22 marzo 13
venerdì 22 marzo 13
Quando eri
  bambino aprivi i
cassetti in camera di
mamma di tuoi amici
   per annusare
     mutande?




venerdì 22 marzo 13
Tell don’t ask



venerdì 22 marzo 13
Ai fornelli



venerdì 22 marzo 13
Uova al tegame

                      In presenza di sufficiente calore, l’albume
                      coagula più rapidamente del tuorlo. che è più
                      digeribile in forma liquida.
                      Un UOVO AL TEGAME si ottiene ponendo
                      l’uovo sgusciato su una superficie piana, calda e
                      non aderente, per un tempo sufficientemente
                      lungo da consentire la coagulazione dell’albume,
                      preservando il tuorlo.


venerdì 22 marzo 13
“Metti un po’ di
                       burro in padella,
                      apri l’uovo e cuoci”


venerdì 22 marzo 13
Non avete bisogno di lui




venerdì 22 marzo 13
Basta lei




venerdì 22 marzo 13
È un uovo!
venerdì 22 marzo 13
Invariant



                      An INVARIANT is a condition that can relied
                      upon to be true during the execution of a
                      program.




venerdì 22 marzo 13
Invarianti?




    Totale = Somma(prezzoUnitario*quantità)
venerdì 22 marzo 13
Comandi?

        CreateEmpty                               ItemAddedToCart
                      to              raises
         RemoveItem    to    Cart   raises      ItemRemovedFromCart
                      to               raises
            AddItem                                 CartCreated




    Totale = Somma(prezzoUnitario*quantità)
venerdì 22 marzo 13
Problema


       - Il prezzo degli articoli può
               variare.



venerdì 22 marzo 13
Quindi?




venerdì 22 marzo 13
Quindi?
                         No, è che ha detto
                  [nome di uno troppo importante
                  per parlare con voi] che il prezzo
                           può cambiare...




venerdì 22 marzo 13
Quindi?
                         No, è che ha detto
                  [nome di uno troppo importante
                  per parlare con voi] che il prezzo
                           può cambiare...

                           ...e va
                      implementata per
                        dopodomani.
venerdì 22 marzo 13
Quindi?
                         No, è che ha detto
                  [nome di uno troppo importante
                  per parlare con voi] che il prezzo
                           può cambiare...

                           ...e va       Doveva già essere
                      implementata per        così.
                        dopodomani.
venerdì 22 marzo 13
Sòla...

venerdì 22 marzo 13
Quindi?




venerdì 22 marzo 13
Quindi?

                         Puoi farmi un
                          esempio?




venerdì 22 marzo 13
Esempio
       - Given item stormtrooper clothing is
               priced €500 each
       - And customer ziobrando added 10
               of stormtrooper clothing to cart
       - When price for stormtrooper
               clothing is updated to €750 each
       - Then ???
venerdì 22 marzo 13
Quindi?




venerdì 22 marzo 13
Quindi?

                        ...?




venerdì 22 marzo 13
Ma anche...




venerdì 22 marzo 13
Ma anche...
                                        Il
                          comportamento dell’utente
                       cambia se la variazione di prezzo è
                      favorevole o sfavorevole: possiamo
                         applicare immediatamente gli
                         sconti, e bloccare i rincari per
                                   un giorno.


venerdì 22 marzo 13
Ma anche...
                                        Il
                          comportamento dell’utente
                       cambia se la variazione di prezzo è
                      favorevole o sfavorevole: possiamo
                         applicare immediatamente gli
                         sconti, e bloccare i rincari per
                                   un per
                           ...ma solo giorno.
                           alcuni articoli
venerdì 22 marzo 13
Che rumore
                       sentite?


venerdì 22 marzo 13
E’	
  necessario	
  un	
  processo	
  di	
  
          sviluppo	
  agile,	
  che	
  perme4a	
  di	
  
         raccogliere	
  il	
  feedback	
  di	
  uten)	
  e	
  
        domain	
  experts,	
  in	
  iterazioni	
  brevi.
            collaborazione creativa                ©	
  Alberto	
  Brandolini	
  2009
venerdì 22 marzo 13
gli esperti ci      e noi aiutiamo
aiutano a capire           loro



                           ©	
  Alberto	
  Brandolini	
  2009
venerdì 22 marzo 13
Bello. Ma oggi...




venerdì 22 marzo 13
Bello. Ma oggi...

                       ...aggiorniamo i
                      prezzi nel carrello




venerdì 22 marzo 13
ItemPriceUpdated
                            to

                      <<EventHandler>>
                         <<Service>>
                             …?


                           raises                                     CartPriceUpdated


                  UpdateItemPrice                         raises
                                         to                             ItemAddedToCart
                      CreateEmpty             to
                                                            raises
                                                   Cart   raises      ItemRemovedFromCart
                                              to
                      RemoveItem                             raises
                                         to                                CartCreated
                        AddItem




venerdì 22 marzo 13
Aggregates
                       all’ostrica

venerdì 22 marzo 13
Domain Model

       - Qui è dove è il sistema a
               prendere le decisioni.
       -       ...sulla basi di quali
               informazioni?


venerdì 22 marzo 13
I dati non sono tutti iguali
    Il sistema prenderà una
    decisone basandosi su
    questi dati




  ..l’utente si baserà su
  questi, ed altro...

venerdì 22 marzo 13
Ho bisogno dell’albume?




venerdì 22 marzo 13
Solo i dati significativi
per l’esecuzione sono
modellati

          CreateEmpty                                   ItemAddedToCart
                          to                raises
           RemoveItem      to     Cart    raises      ItemRemovedFromCart
                          to                 raises
               AddItem                                    CartCreated


                         ...tutto il contenuto
                         informativo è propagato
                         attraverso gli eventi
venerdì 22 marzo 13
Che ci faccio con l’albume?




venerdì 22 marzo 13
Che ci faccio con l’albume?




venerdì 22 marzo 13
...il read model!


                      Read Model                          n

                                   updates   Projection




venerdì 22 marzo 13
I sapori fondamentali




venerdì 22 marzo 13
I sapori fondamentali
                      Dolce




venerdì 22 marzo 13
I sapori fondamentali
                      Dolce
                      Amaro




venerdì 22 marzo 13
I sapori fondamentali
                      Dolce
                      Amaro
                      Salato




venerdì 22 marzo 13
I sapori fondamentali
                      Dolce
                      Amaro
                      Salato
                      Aspro


venerdì 22 marzo 13
I sapori fondamentali
                      Dolce
                      Amaro
                      Salato
                      Aspro
                      Umami
venerdì 22 marzo 13
Che [*] é umami?


     [*] = Colorita espressione regionale
venerdì 22 marzo 13
Che [*] é un
                      invariante?


     [*] = Colorita espressione regionale
venerdì 22 marzo 13
3 modelli

       - Costruzione
       - Esecuzione
       - Controllo


venerdì 22 marzo 13
...le invarianti si semplificano

       -       comportamento differenziato
       - condizioni più precise
       - possibilità di applicare una
               differente semantica: es
               warning vs blocker
       - fare le domande giuste
venerdì 22 marzo 13
Davvero avete
                 così fretta?

venerdì 22 marzo 13
Comunque...




                                geteventstore.com
venerdì 22 marzo 13
Domain-Driven Design
                      Eric Evans

                           Enterprise Integration
                                         Patterns
                       Gregor Hohpe, Bobby Woolf



                      Patterns of Enterprise
                      Application Architecture
                      Martin Fowler


                         Per saperne di più... www.avanscoperta.it
venerdì 22 marzo 13
Implementing Domain-Driven Design
  Vaughn Vernon


http://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577




                                   Event Centric
                                   Greg Young

                                    http://www.amazon.com/Event-Centric-Simplicity-Addison-Wesley-Signature/dp/0321768221




                                    Per saperne di più... www.avanscoperta.it
venerdì 22 marzo 13
venerdì 22 marzo 13
Grazie!
                       @ziobrando
          Alberto.brandolini@avanscoperta.it




venerdì 22 marzo 13

Mais conteúdo relacionado

Destaque

Ricetta Si Impersonale
Ricetta Si ImpersonaleRicetta Si Impersonale
Ricetta Si Impersonale
xelogom
 
Ricette pesce acqua dolce
Ricette pesce acqua dolceRicette pesce acqua dolce
Ricette pesce acqua dolce
Rita Lo Iacono
 
Il vino è ...nutrimento
Il vino è ...nutrimentoIl vino è ...nutrimento
Il vino è ...nutrimento
FrancescaR2015
 
Alimentazione Equilibrata
Alimentazione EquilibrataAlimentazione Equilibrata
Alimentazione Equilibrata
ritaberna
 
I principi nutritivi
I principi nutritiviI principi nutritivi
I principi nutritivi
Laprof Russo
 
Principi Nutritivi O Nutrienti
Principi Nutritivi O NutrientiPrincipi Nutritivi O Nutrienti
Principi Nutritivi O Nutrienti
Dario
 
I MACRONUTRIENTI
I MACRONUTRIENTII MACRONUTRIENTI
I MACRONUTRIENTI
albero
 
Alimenti e nutrienti2
Alimenti e nutrienti2Alimenti e nutrienti2
Alimenti e nutrienti2
Laura Grassi
 

Destaque (17)

Antiche ricette di medicamenti
Antiche ricette di medicamentiAntiche ricette di medicamenti
Antiche ricette di medicamenti
 
PIATTI DA SALVARE - Ricette della tradizione italiana ----disponibile App per...
PIATTI DA SALVARE - Ricette della tradizione italiana ----disponibile App per...PIATTI DA SALVARE - Ricette della tradizione italiana ----disponibile App per...
PIATTI DA SALVARE - Ricette della tradizione italiana ----disponibile App per...
 
Ricetta Si Impersonale
Ricetta Si ImpersonaleRicetta Si Impersonale
Ricetta Si Impersonale
 
Ricette pesce acqua dolce
Ricette pesce acqua dolceRicette pesce acqua dolce
Ricette pesce acqua dolce
 
Macro V.s Micro Nutrienti
 Macro V.s Micro Nutrienti Macro V.s Micro Nutrienti
Macro V.s Micro Nutrienti
 
Il vino è ...nutrimento
Il vino è ...nutrimentoIl vino è ...nutrimento
Il vino è ...nutrimento
 
Ricetta power point
Ricetta power pointRicetta power point
Ricetta power point
 
Ricette dal mondo
Ricette dal mondoRicette dal mondo
Ricette dal mondo
 
La cucina degli avanzi attraverso le ricette contadine
La cucina degli avanzi attraverso le ricette contadineLa cucina degli avanzi attraverso le ricette contadine
La cucina degli avanzi attraverso le ricette contadine
 
Introduzione ad una dieta sana
Introduzione ad una dieta sanaIntroduzione ad una dieta sana
Introduzione ad una dieta sana
 
Alimentazione Equilibrata
Alimentazione EquilibrataAlimentazione Equilibrata
Alimentazione Equilibrata
 
I principi nutritivi
I principi nutritiviI principi nutritivi
I principi nutritivi
 
Principi Nutritivi O Nutrienti
Principi Nutritivi O NutrientiPrincipi Nutritivi O Nutrienti
Principi Nutritivi O Nutrienti
 
Nutrienti e geni: un dialogo alla base della nostra salute
Nutrienti e geni: un dialogo alla base della nostra saluteNutrienti e geni: un dialogo alla base della nostra salute
Nutrienti e geni: un dialogo alla base della nostra salute
 
I MACRONUTRIENTI
I MACRONUTRIENTII MACRONUTRIENTI
I MACRONUTRIENTI
 
Il pane power point
Il pane power pointIl pane power point
Il pane power point
 
Alimenti e nutrienti2
Alimenti e nutrienti2Alimenti e nutrienti2
Alimenti e nutrienti2
 

Mais de Codemotion

Mais de Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Ricette veloci per Domain-Driven Design by Alberto Brandolini

  • 1. Ricette veloci per Domain- Driven Design dal menù di @ziobrando venerdì 22 marzo 13
  • 2. About me In the IT field since ZX Spectrum Generally in large scale projects (I might be biased) Strategic IT Consultant Trainer (Avanscoperta & Skills Matter) Technical Writer Blogger: http://ziobrando.blogspot.com Twitter: @ziobrando My e-mail: alberto.brandolini@gmail.com venerdì 22 marzo 13
  • 3. About me Mi piace risolvere problemi O scrivere software che li risolva Blogger: http://ziobrando.blogspot.com Twitter: @ziobrando My e-mail: alberto.brandolini@gmail.com venerdì 22 marzo 13
  • 4. About me In the IT field since ZX Spectrum Generally in large scale projects (I might be biased) Strategic IT Consultant Trainer (Avanscoperta & Skills Matter) Technical Writer Blogger: http://ziobrando.blogspot.com Twitter: @ziobrando My e-mail: alberto.brandolini@gmail.com venerdì 22 marzo 13
  • 5. Aggregates It is difficult to guarantee the consistency of changes to objects in a model with complex associations. Invariants need to be maintained that apply to closely related groups of objects, not just discrete objects. An AGGREGATE is a cluster of associated objects that we treat as a unit for the purpose of data changes. venerdì 22 marzo 13
  • 7. Customer! Customer venerdì 22 marzo 13
  • 8. Customer! <<Entity>> Customer venerdì 22 marzo 13
  • 9. Customer! <<Aggregate Root>> <<Entity>> Customer venerdì 22 marzo 13
  • 10. Customer! <<Aggregate Root>> <<Entity>> Customer nome cognome venerdì 22 marzo 13
  • 11. Customer! <<Aggregate Root>> <<Entity>> Customer nome cognome username emailAddress venerdì 22 marzo 13
  • 12. Customer! <<Aggregate Root>> <<Entity>> Customer nome cognome username emailAddress address country language venerdì 22 marzo 13
  • 14. Domande? - Persistenza? venerdì 22 marzo 13
  • 15. Domande? - Persistenza? - Fa tutto lui! :-) venerdì 22 marzo 13
  • 16. Domande? - Persistenza? - Fa tutto lui! :-) - Come gestisco address? venerdì 22 marzo 13
  • 17. Domande? - Persistenza? - Fa tutto lui! :-) - Come gestisco address? - Dove tengo la password? venerdì 22 marzo 13
  • 18. Domande? - Persistenza? - Fa tutto lui! :-) - Come gestisco address? - Dove tengo la password? venerdì 22 marzo 13
  • 19. Domande? - Persistenza? - Fa tutto lui! :-) - Come gestisco address? - Dove tengo la password? venerdì 22 marzo 13
  • 21. Dov’è il comportamento? venerdì 22 marzo 13
  • 23. Trucco N°1 - CQRS Command/Query Responsibility Segregation venerdì 22 marzo 13
  • 24. ! Architettura ottimizzata per i comandi ? venerdì 22 marzo 13 Architettura ottimizzata per le letture
  • 25. Domain Model Command Aggregate Event Event store Event Event Event UI Event Command Aggregate Event Presentation Event UI Event UI Projection DTO Projection UI DTO Read Model venerdì 22 marzo 13
  • 27. Non parleremo di questo... venerdì 22 marzo 13
  • 28. Conceptual CQRS Command to Domain Model raises issues Event User Read Model influences notified to influences updates Projection External information Warning! non è architettura... venerdì 22 marzo 13
  • 29. Qui decide l’utente Command issues User Read Model influences influences External information venerdì 22 marzo 13
  • 31. User Steps - L’utente decide quali comandi invocare sul sistema sulla base delle informazioni derivanti dalla sua esperienza, e da quanto reso disponibile dall’applicazione venerdì 22 marzo 13
  • 32. Examples? - Timesheet entry venerdì 22 marzo 13
  • 33. Conceptual CQRS Command to Domain Model raises issues Event User Read Model influences notified to influences updates Projection External information venerdì 22 marzo 13
  • 34. Vi ho tolto il DB! venerdì 22 marzo 13
  • 36. Conceptual CQRS Command to Domain Model raises issues Event User Read Model influences notified to influences updates Projection External information venerdì 22 marzo 13
  • 37. Aggregates It is difficult to guarantee the consistency of changes to objects in a model with complex associations. Invariants need to be maintained that apply to closely related groups of objects, not just discrete objects. An AGGREGATE is a cluster of associated objects that we treat as a unit for the purpose of data changes. venerdì 22 marzo 13
  • 39. Aggregate History - Propagazione venerdì 22 marzo 13
  • 40. Aggregate History - Propagazione - 2004 una generica “comunicazione asincrona” venerdì 22 marzo 13
  • 41. Aggregate History - Propagazione - 2004 una generica “comunicazione asincrona” - 2010 ... Domain Events venerdì 22 marzo 13
  • 42. Aggregate History - Propagazione - 2004 una generica “comunicazione asincrona” - 2010 ... Domain Events - Struttura interna: venerdì 22 marzo 13
  • 43. Aggregate History - Propagazione - 2004 una generica “comunicazione asincrona” - 2010 ... Domain Events - Struttura interna: - 2004: “Don’t fight your frameworks” venerdì 22 marzo 13
  • 44. Aggregate History - Propagazione - 2004 una generica “comunicazione asincrona” - 2010 ... Domain Events - Struttura interna: - 2004: “Don’t fight your frameworks” - ORM / NoSQL / Event Sourcing / Functional... venerdì 22 marzo 13
  • 45. Domain Model Command to Domain Model raises Event venerdì 22 marzo 13
  • 46. Domain Model - Qui è dove è il sistema a prendere le decisioni. venerdì 22 marzo 13
  • 47. I dati non sono tutti iguali Il sistema prenderà una decisone basandosi su questi dati ..l’utente si baserà su questi, ed altro... venerdì 22 marzo 13
  • 49. Domain Model Command to Domain Model raises Event venerdì 22 marzo 13
  • 51. Non ci guardo dentro... venerdì 22 marzo 13
  • 53. ... ...ma se devo prendere le informazioni da un’altro aggregato? venerdì 22 marzo 13
  • 55. Quando eri bambino aprivi i cassetti in camera di mamma di tuoi amici per annusare mutande? venerdì 22 marzo 13
  • 58. Uova al tegame In presenza di sufficiente calore, l’albume coagula più rapidamente del tuorlo. che è più digeribile in forma liquida. Un UOVO AL TEGAME si ottiene ponendo l’uovo sgusciato su una superficie piana, calda e non aderente, per un tempo sufficientemente lungo da consentire la coagulazione dell’albume, preservando il tuorlo. venerdì 22 marzo 13
  • 59. “Metti un po’ di burro in padella, apri l’uovo e cuoci” venerdì 22 marzo 13
  • 60. Non avete bisogno di lui venerdì 22 marzo 13
  • 62. È un uovo! venerdì 22 marzo 13
  • 63. Invariant An INVARIANT is a condition that can relied upon to be true during the execution of a program. venerdì 22 marzo 13
  • 64. Invarianti? Totale = Somma(prezzoUnitario*quantità) venerdì 22 marzo 13
  • 65. Comandi? CreateEmpty ItemAddedToCart to raises RemoveItem to Cart raises ItemRemovedFromCart to raises AddItem CartCreated Totale = Somma(prezzoUnitario*quantità) venerdì 22 marzo 13
  • 66. Problema - Il prezzo degli articoli può variare. venerdì 22 marzo 13
  • 68. Quindi? No, è che ha detto [nome di uno troppo importante per parlare con voi] che il prezzo può cambiare... venerdì 22 marzo 13
  • 69. Quindi? No, è che ha detto [nome di uno troppo importante per parlare con voi] che il prezzo può cambiare... ...e va implementata per dopodomani. venerdì 22 marzo 13
  • 70. Quindi? No, è che ha detto [nome di uno troppo importante per parlare con voi] che il prezzo può cambiare... ...e va Doveva già essere implementata per così. dopodomani. venerdì 22 marzo 13
  • 73. Quindi? Puoi farmi un esempio? venerdì 22 marzo 13
  • 74. Esempio - Given item stormtrooper clothing is priced €500 each - And customer ziobrando added 10 of stormtrooper clothing to cart - When price for stormtrooper clothing is updated to €750 each - Then ??? venerdì 22 marzo 13
  • 76. Quindi? ...? venerdì 22 marzo 13
  • 78. Ma anche... Il comportamento dell’utente cambia se la variazione di prezzo è favorevole o sfavorevole: possiamo applicare immediatamente gli sconti, e bloccare i rincari per un giorno. venerdì 22 marzo 13
  • 79. Ma anche... Il comportamento dell’utente cambia se la variazione di prezzo è favorevole o sfavorevole: possiamo applicare immediatamente gli sconti, e bloccare i rincari per un per ...ma solo giorno. alcuni articoli venerdì 22 marzo 13
  • 80. Che rumore sentite? venerdì 22 marzo 13
  • 81. E’  necessario  un  processo  di   sviluppo  agile,  che  perme4a  di   raccogliere  il  feedback  di  uten)  e   domain  experts,  in  iterazioni  brevi. collaborazione creativa ©  Alberto  Brandolini  2009 venerdì 22 marzo 13
  • 82. gli esperti ci e noi aiutiamo aiutano a capire loro ©  Alberto  Brandolini  2009 venerdì 22 marzo 13
  • 84. Bello. Ma oggi... ...aggiorniamo i prezzi nel carrello venerdì 22 marzo 13
  • 85. ItemPriceUpdated to <<EventHandler>> <<Service>> …? raises CartPriceUpdated UpdateItemPrice raises to ItemAddedToCart CreateEmpty to raises Cart raises ItemRemovedFromCart to RemoveItem raises to CartCreated AddItem venerdì 22 marzo 13
  • 86. Aggregates all’ostrica venerdì 22 marzo 13
  • 87. Domain Model - Qui è dove è il sistema a prendere le decisioni. - ...sulla basi di quali informazioni? venerdì 22 marzo 13
  • 88. I dati non sono tutti iguali Il sistema prenderà una decisone basandosi su questi dati ..l’utente si baserà su questi, ed altro... venerdì 22 marzo 13
  • 90. Solo i dati significativi per l’esecuzione sono modellati CreateEmpty ItemAddedToCart to raises RemoveItem to Cart raises ItemRemovedFromCart to raises AddItem CartCreated ...tutto il contenuto informativo è propagato attraverso gli eventi venerdì 22 marzo 13
  • 91. Che ci faccio con l’albume? venerdì 22 marzo 13
  • 92. Che ci faccio con l’albume? venerdì 22 marzo 13
  • 93. ...il read model! Read Model n updates Projection venerdì 22 marzo 13
  • 95. I sapori fondamentali Dolce venerdì 22 marzo 13
  • 96. I sapori fondamentali Dolce Amaro venerdì 22 marzo 13
  • 97. I sapori fondamentali Dolce Amaro Salato venerdì 22 marzo 13
  • 98. I sapori fondamentali Dolce Amaro Salato Aspro venerdì 22 marzo 13
  • 99. I sapori fondamentali Dolce Amaro Salato Aspro Umami venerdì 22 marzo 13
  • 100. Che [*] é umami? [*] = Colorita espressione regionale venerdì 22 marzo 13
  • 101. Che [*] é un invariante? [*] = Colorita espressione regionale venerdì 22 marzo 13
  • 102. 3 modelli - Costruzione - Esecuzione - Controllo venerdì 22 marzo 13
  • 103. ...le invarianti si semplificano - comportamento differenziato - condizioni più precise - possibilità di applicare una differente semantica: es warning vs blocker - fare le domande giuste venerdì 22 marzo 13
  • 104. Davvero avete così fretta? venerdì 22 marzo 13
  • 105. Comunque... geteventstore.com venerdì 22 marzo 13
  • 106. Domain-Driven Design Eric Evans Enterprise Integration Patterns Gregor Hohpe, Bobby Woolf Patterns of Enterprise Application Architecture Martin Fowler Per saperne di più... www.avanscoperta.it venerdì 22 marzo 13
  • 107. Implementing Domain-Driven Design Vaughn Vernon http://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577 Event Centric Greg Young http://www.amazon.com/Event-Centric-Simplicity-Addison-Wesley-Signature/dp/0321768221 Per saperne di più... www.avanscoperta.it venerdì 22 marzo 13
  • 109. Grazie! @ziobrando Alberto.brandolini@avanscoperta.it venerdì 22 marzo 13