Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Loosely Coupled Complexity - Unleash the power of your domain model

959 views

Published on

Common software architectures are full of well-established assumptions. But some of them are flawed, no longer valid or relevant. Changing the rules of the game using DDD, CQRS and Event Sourcing can lead to systems which are more scalable, maintainable and performing. And which are fun to code as well.

Published in: Technology, Business
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Loosely Coupled Complexity - Unleash the power of your domain model

  1. 1. Loosely Coupled Complexity <ul><li>Unleash the power of your Domain Model using CQRS & Event Sourcing </li></ul>[email_address]
  2. 2. About me <ul><li>In the IT field since ZX Spectrum </li></ul><ul><li>Generally in large scale projects (I might be biased ) </li></ul><ul><li>Freelance consultant: NotOnlyCode </li></ul><ul><li>Trainer (Freelance & Skills Matter + Zenika) </li></ul><ul><li>Technical Writer </li></ul><ul><li>Blogger: http://ziobrando.blogspot.com </li></ul><ul><li>Twitter: ziobrando </li></ul>My e-mail: [email_address]
  3. 3. <ul><li>@avanscoperta </li></ul><ul><li>www.avanscoperta.it </li></ul><ul><li>avanscoperta.wordpress.com </li></ul><ul><li>[email_address] </li></ul>
  4. 4. Questi 3 tipi hanno qualcosa di veramente interessante da dire...
  5. 5. Cosa c’è che non va? UI Remote facade Application Services DTO DTO ORM
  6. 6. niente
  7. 7. Thank you <ul><li>[email_address] </li></ul><ul><li>http://ziobrando.blogspot.com </li></ul><ul><li>twitter: ziobrando </li></ul>
  8. 8. - Quale gobba?
  9. 9. Quante assunzioni stanno guidando le nostre decisioni?
  10. 10. Proviamo ancora... UI Remote facade Application Services DTO DTO ORM
  11. 11. <ul><li>Anaemic Domain Model </li></ul><ul><li>i DTO? </li></ul><ul><li>Ottimizzazione query su ORM </li></ul><ul><li>Tempo di sviluppo </li></ul><ul><li>Testabilità </li></ul><ul><li>... </li></ul>
  12. 12. <ul><li>Abbiamo veramente bisogno di... </li></ul><ul><ul><li>un Domain Model? </li></ul></ul><ul><ul><li>un Database? </li></ul></ul><ul><ul><li>transazioni? </li></ul></ul><ul><ul><li>un Object Relational Mapper? </li></ul></ul><ul><ul><li>DTO? </li></ul></ul>
  13. 13. Anaemic Domain Model
  14. 14. Non tutti i regali sono necessariamente graditi...
  15. 15. Vantaggi dell’Anaemic Domain Model 1) Il codice business è localizzato in un solo posto: Più facile da leggere per sviluppatori giovani non familiari con OOP. Spiacente ...non c’è il numero 2 :-(
  16. 16. Svantaggi dell’Anemic Domain Model Triste come un pasto in ospedale difficile da matenere difficile da testare alimenta la duplicazione
  17. 17. <ul><li>Progettate la vistra applicazione partendo dal data model </li></ul><ul><li>Create il vostro domain model via reverse engineering </li></ul><ul><li>Dichiarate di fare TDD e cominciate a testare le vostre classi di dominio </li></ul><ul><ul><li>In particolare i getter ed i setters </li></ul></ul><ul><li>Quindi, testate la logica con i test d’Integrazione, ed impantanatevi con i dati di test. </li></ul><ul><li>Dichiarate ufficialmente che TDD non porta alcun vantaggio e che vi fa solo rallentare. </li></ul><ul><li>Commentate i tests nel vostro script di Build - Continuous Integration </li></ul><ul><li>Continuate a lamentarvi </li></ul>Come farsi del male da soli
  18. 18. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  19. 19. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  20. 20. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  21. 21. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  22. 22. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  23. 23. <ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul><ul><li>Non farò più il reverse engineering del data model per creare un domain model </li></ul>
  24. 24. Come dovremmo implementare un Domain Model? Fate in modo che il codice parli lo Ubiquitous Language Proteggete il vostro modello con dei Bounded Contexts Usate gli Aggregati come unità di consistenza nel vostro domain model Il comportamento dovrebbe risiedere nel Domain Model
  25. 25. Anemic Domain Model
  26. 26. Rich domain model
  27. 27. TDD e DDD Riscritture frequenti Exploratory coding Domain Objects minimali Focus sugli Unit Tests Tiny Domain Objects Tiny Domain Objects Cicli corti e frequenti Codice autoesplicativo Feedback rapido Libertà di cambiare
  28. 28. Aggregate Un gruppo di oggetti naturalmente vicini Unità di consistenza nel domain model modificati nella stessa transazione cancellati insieme trasferiti insieme
  29. 29. Aggregati multipli
  30. 30. Ma la duplicazione non era il male? <ul><li>Se pensiamo ai “dati” allora ...c’è duplicazione </li></ul><ul><li>Se pensiamo al “comportamento” allora alcuni oggetti non sono la stessa cosa </li></ul><ul><li>stabilire i confini degli aggregati rende il nostro sistema </li></ul><ul><ul><li>strettamente consistente all’interno degli aggregate boundaries </li></ul></ul><ul><ul><li>eventualmente consistente al di fuori dei confini dell’aggregato </li></ul></ul>
  31. 31. Alla fine è piuttosto semplice
  32. 32. Perchè complicarsi la vita?
  33. 33. Hmm... Una volta che l’accoppiamento tra gli aggregati è ridotto... potrei anche pensare di scegliere una strategia di persistenza differente per ogni aggregato...
  34. 34. dalla cara vecchia architettura... UI Remote facade Application Services DTO DTO ORM
  35. 35. La visione DDD classica UI Remote facade Application Services DTO DTO ORM bounded contexts aggregate boundaries thin application layer
  36. 36. Portiamo i Domain Objects alla UI? <ul><li>I DTO non piacciono a nessuno... </li></ul><ul><li>Alcuni tool lo permettono! (hey, c’è una camicia hawaiana in regalo!!) </li></ul><ul><li>Il delirio della validazione </li></ul><ul><li>Gli oggetti a 2 stati </li></ul><ul><ul><li>la tentazione del Framework </li></ul></ul>
  37. 37. Come implementereste queste? As a Marketing Office I want to assign discount points to customer on every purchase In order to enable more deals in the future As a Sales Office I want to ship order on purchase command In order to deliver purchased goods to the customer
  38. 38. Eventi e coordinamento fra aggregati <ul><li>Operazione che coinvolgono più aggregati non dovrebbero essere nella stessa Unit of Work </li></ul><ul><li>La comunicazione fra aggregati è intrisecamente asincrona </li></ul><ul><li>Domain Events come meccanismo di comunicazione </li></ul><ul><ul><li>dall’esterno </li></ul></ul><ul><ul><li>fra aggregati </li></ul></ul>
  39. 39. Domain Event <ul><li>nello Ubiquitous Language , sono Azioni Completate : verbi al passato. </li></ul>
  40. 40. Rispondere asincronamente agli eventi <ul><li>Non dimentichiamo: il legame vero tra le azioni è definito dal business!!! </li></ul>
  41. 41. a qualcuno ricorda SOA ? ...proviamo a disegnare le cose diversamente e pensare alla “granularità dei servizi” ...proviamo a disegnare le cose diversamente e pensare alla “granularità dei servizi”
  42. 42. Command/Query Responsibility Segregation Segregation
  43. 44. perché trovare un compromesso ?
  44. 45. Partendo dal piccolo... <ul><li>Command/Query Separation era un principio OOD incluso in DDD </li></ul><ul><ul><li>accessors non dovrebbero avere side effects </li></ul></ul><ul><ul><li>mutators non dovrebbero ritornare un valore </li></ul></ul><ul><ul><ul><li>(con ll’eccezione di this in alcuni casi) </li></ul></ul></ul>
  45. 46. ! Di solito indirizzati ad entità singole il comportamento è importante la Flessibilità è importante Command
  46. 47. ? Grosse quantità di dati Non c’è comportamento le Prestazioni sono importanti Disponibili numerosi componenti off-the shelf Query
  47. 48. da questo... UI Remote facade Application Services DTO DTO ORM
  48. 49. ...a questo UI Remote facade Application Services ORM Remote facade Thin Read Layer DTO DTO
  49. 50. Un percorso separato per comandi inviati al Domain Model Un percorso separato per recuperare Dati
  50. 51. Querying <ul><li>Date un’occhiata ai vostri utenti , cosa interessa loro veramente? </li></ul><ul><ul><li>Non è cercare, è trovare </li></ul></ul><ul><ul><li>Non è il refresh , stanno cercando eventi </li></ul></ul>
  51. 52. Staleness <ul><li>È veramente un problema ? </li></ul><ul><li>Importa veramente se i dati sono... </li></ul><ul><ul><li>di 20 secondi fa? </li></ul></ul><ul><ul><li>O di 10 minuti ? </li></ul></ul><ul><li>... chi siamo noi per decidere questa cosa? </li></ul><ul><li>... puoi tenere sincronizzata una stampa ? </li></ul><ul><ul><li>o un PowerPoint ? </li></ul></ul>
  52. 53. Sono solo dati <ul><li>Non c’è comportamento in quello che vediamo. </li></ul><ul><li>Abbiamo veramente bisogno di oggetti ? </li></ul>
  53. 54. Query-Only Architecture <ul><li>Sono solo dati: no comportamento... </li></ul><ul><ul><li>=> perché non andare dritti sul database ? </li></ul></ul><ul><li>Non c’è accoppiamento tra le schermate della UI... </li></ul><ul><ul><li>=> Abbiamo veramente bisogno della referential integrity? </li></ul></ul><ul><ul><li>=> Perché non usare una table-per-UI-view strategy, calcolata in background? </li></ul></ul><ul><li>Cosa stiamo già facendo con il search model e con la cache ? </li></ul>
  54. 55. Anche i dati stale possono <ul><li>... fornire informazioni utili per la validazione preliminare dei comandi </li></ul><ul><ul><li>=> meno comandi che falliscono </li></ul></ul>
  55. 56. ...meno comandi che falliscono <ul><li>Se la maggio parte dei nostri comandi avrà successo... </li></ul><ul><li>... c’è veramente bisogno di rispondere immediatamente o sullo stesso canale ? </li></ul><ul><li>Perché non qualcosa come: “ Thank you for your order, your confirmation e-mail will arrive shortly ”? </li></ul>
  56. 57. Catturare le intenzioni dell’utente <ul><li>Sappiamo realmente cosa l’utente vuole fare con la nostra applicazione ? </li></ul><ul><li>Stiamo realmente supportando i nostri utenti? </li></ul><ul><li>Chi si sta facendo carico della complessità? </li></ul><ul><li>... non possiamo fare qualcosa di più intelligente che semplicemente mostrare dati grezzi ? </li></ul><ul><ul><li>...un sacco di carico sul versante dati è sostanzialmente inutile </li></ul></ul>
  57. 58. Commands != Entities <ul><li>Non c’è molto in comune... </li></ul><ul><ul><li>per quale motivo devo mostrarle all’utente? </li></ul></ul>
  58. 59. Write-only model <ul><li>Il domain model non è usato per recuperare o mostrare dati. </li></ul><ul><ul><li>Le relazioni tra entità orientate al recupero dei dati ... non sono più necessarie </li></ul></ul><ul><li>Il Domain Model è sempre in uno stato consistente (dalla Factory alla Garbage Collection) </li></ul><ul><li>Non è necessaria la validazione sul Domain Model (comandi sono validati prima ) </li></ul><ul><li>Testare il Domain Model diventa ancora più semplice </li></ul>
  59. 60. Persisting the model <ul><li>Abbiamo veramente bisogno di rendere persistenti tutti i dati ? </li></ul><ul><li>Abbiamo veramente bisogno di renderli persistenti su un supporto Relazionale ? </li></ul><ul><ul><li>(ricordate, non stiamo facendo query sul modello...) </li></ul></ul>
  60. 61. UI Remote facade Application Services ORM Remote facade Thin Read Layer DTO Commands
  61. 62. voilà UI Remote facade Application Services ORM? Remote facade Thin Read Layer DTO publish subscribe Specialized data model does it really need to be relational? Commands Eventually
  62. 63. un interessante side effect <ul><li>... meno collections ... </li></ul><ul><li>=> meno impatto sulla memoria </li></ul><ul><li>=> meno Garbage Collection </li></ul><ul><li>su alcuni sistemi, il Domain Model è sempre disponibile </li></ul>
  63. 64. The paper-based system Molti tipi di azienda nascono prima dei computers Le transazioni non sono un problema bisiness I Dati possono essere disallineati...capita CHIEDIAMO al Business
  64. 65. Event Sourcing
  65. 66. Quindi ...cosa fa il nostro Domain Model? <ul><li>fondamentalmente risponde a messaggi autocontenuti provenienti dall’esterno... </li></ul><ul><ul><li>eventi dalla UI o da sorgenti esterne </li></ul></ul>
  66. 67. La singola sorgente di verità <ul><li>Un tempo era la carta ... </li></ul><ul><li>ora sono gli Eventi </li></ul>
  67. 68. voilà UI Remote facade Application Services ORM ? Remote facade Thin Read Layer DTO publish subscribe Events Events
  68. 69. Dobbiamo tenere lo stato nelle Entities? <ul><li>Abbiamo tutte le informazioni necessarie nella Event Queue </li></ul><ul><ul><li>SINGLE SOURCE of TRUTH </li></ul></ul><ul><li>Cos’è un Aggregato? qualcosa che cambia il suo stato in risposta ad eventi </li></ul><ul><ul><li>...secondo il nostro livello attuale di comprensione del sistema </li></ul></ul>
  69. 70. Aggregati ed eventi <ul><li>Gli aggregati tengono traccia degli eventi e derivano il proprio comportamento di conseguenza </li></ul>
  70. 71. Che succede se... <ul><li>deriviamo lo stato degli Aggregati dalla sequenza degli eventi che sono avvenuti in un sistema? </li></ul><ul><li>=> Possiamo avere feaures retroattive ... </li></ul><ul><li>=> Possiamo rispondere SI ad un sacco di richieste strane/interessanti che arrivano dal business. </li></ul><ul><li>=> Riprodurre bug ? </li></ul>
  71. 73. Gli aggregati disaccoppiati permettono semplificazioni nello sviluppo La terra delle opportunità Polyglot persistence migliore scalabilità Polyglot persistence Polyglot persistence Polyglot persistence SOA indolore Applicazioni riavvolgibili
  72. 74. Una cosa alla volta Non è detto che abbiate bisogno di tutto Ogni step è un miglioramento Anche in piccole architetture ...Mettiamo in discussione un’assunzione alla volta ...Mettiamo in discussione un’assunzione alla volta ...Mettiamo in discussione un’assunzione alla volta ...Mettiamo in discussione un’assunzione alla volta ...Mettiamo in discussione un’assunzione alla volta
  73. 77. References <ul><li>http://groups.google.com/group/dddcqrs </li></ul><ul><li>http://cqrs.wordpress.com/ </li></ul><ul><li>http://www.infoq.com/interviews/Architecture-Eric-Evans-Interviews-Greg-Young </li></ul><ul><li>http://www.udidahan.com/2009/12/09/clarified-cqrs/ </li></ul><ul><li>http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation </li></ul><ul><li>http://www.infoq.com/presentations/SOA-Business-Autonomous-Components </li></ul><ul><li>http://martinfowler.com/eaaDev/EventSourcing.html </li></ul><ul><li>http://skillsmatter.com/podcast/design-architecture/architectural-innovation-eventing-event-sourcing </li></ul>
  74. 78. Thank you <ul><li>[email_address] </li></ul><ul><li>http://ziobrando.blogspot.com </li></ul><ul><li>twitter: ziobrando </li></ul>

×