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.

8

Share

All our aggregates are wrong (ExploreDDD 2018)

It always starts well. At first glance the requirements seem straightforward, and implementation proceeds without hiccups. Then the requirements start to get more complex, and you find yourself in a predicament, introducing technical shortcuts that smell for the sake of delivering the new feature on schedule. In this talk, we'll analyze what appears to be a straightforward e-commerce shopping cart. We'll then go ahead and add a few more use-cases that make it more complex and see how it can negatively impact the overall design. Finally, we'll focus our attention to the business needs of these requirements and see how it can shed light on the correct approach to designing the feature. Walk away with a new understanding on how to take requirements apart to build the right software.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

All our aggregates are wrong (ExploreDDD 2018)

  1. 1. @mauroservienti | #EDDD all our aggregates are wrong Mauro Servienti @mauroservienti
  2. 2. @mauroservienti | #EDDD All I wanna do when I wake up in the morning is… Rosanna, Toto. Toto IV
  3. 3. @mauroservienti | #EDDD Buy a "Banana Protector"
  4. 4. @mauroservienti | #EDDD Buy a "Banana Protector"
  5. 5. @mauroservienti | #EDDD Sounds like a nice looking aggregate [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart
  6. 6. @mauroservienti | #EDDD It even has behaviors
  7. 7. @mauroservienti | #EDDD please, welcome the business
  8. 8. @mauroservienti | #EDDD Business requirements (#1)
  9. 9. @mauroservienti | #EDDD Straightforward, isn’t it? [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price Sales
  10. 10. @mauroservienti | #EDDD Straightforward, isn’t it? [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Price Sales copy
  11. 11. @mauroservienti | #EDDD Business requirements (#2)
  12. 12. @mauroservienti | #EDDD Still not a big deal… - Item ID - Price Sales [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart copy - Item ID - Inventory Warehouse copy
  13. 13. @mauroservienti | #EDDD - Item ID - Price Sales [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Inventory Warehouse However, availability changes over time Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory copy
  14. 14. @mauroservienti | #EDDD Business requirements (#3)
  15. 15. @mauroservienti | #EDDD - Item ID - Inventory Warehouse …uhm… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales [ list-of ] - Item ID - Price - Quantity - Inventory - Name - Description Shopping Cart
  16. 16. @mauroservienti | #EDDD - Item ID - Inventory Warehouse …uhm… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales [ list-of ] - Item ID - Price - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart
  17. 17. @mauroservienti | #EDDD - Item ID - Inventory Warehouse …uhm… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales [ list-of ] - Item ID - Price - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart Is item XYZ in a cart? Swap & Insert Prices
  18. 18. @mauroservienti | #EDDD - Item ID - Inventory Warehouse …uhm… Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales [ list-of ] - Item ID - Price - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart Is item XYZ in a cart? Swap & Insert Prices Move to Saved for…
  19. 19. @mauroservienti | #EDDD - Item ID - Inventory Warehouse It’s becoming messy, isn’t it? - Item ID - Price Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Update XYZ inventory Is item XYZ in a cart? Swap & Insert Prices Move to Saved for… Is item XYZ in a cart? Swap & Insert Prices Move to Saved for…
  20. 20. @mauroservienti | #EDDD The big picture is even messier! [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description Shopping Cart - Item ID - Inventory Warehouse Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales - Item ID - Name - Description Marketing copy Is item XYZ in a cart? Swap & Insert Prices Move to Saved for…
  21. 21. @mauroservienti | #EDDD …and messier! [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description - Estimated Delivery Shopping Cart - Item ID - Inventory Warehouse Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales Is item XYZ in a cart? Swap & Insert Prices - Item ID - Name - Description Marketing copy - Item ID - Delivery Type Shipping Is item XYZ in a cart? Update XYZ delivery Move to Saved for…
  22. 22. @mauroservienti | #EDDD autonomy? puff, it’s gone
  23. 23. @mauroservienti | #EDDD Can we get rid of all this coupling? [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Inventory - Name - Description - Estimated Delivery Shopping Cart - Item ID - Inventory Warehouse Is item XYZ in a cart? Update XYZ inventory - Item ID - Price Sales - Item ID - Name - Description Marketing copy - Item ID - Delivery Type Shipping Is item XYZ in a cart? Update XYZ delivery Is item XYZ in a cart? Swap & Insert Prices Move to Saved for…
  24. 24. @mauroservienti | #EDDD shopping cart doesn’t exist
  25. 25. @mauroservienti | #EDDD Sales shopping cart [ list-of ] - Item ID - Quantity - Inventory - Name - Description - Delivery Est. Shopping Cart Warehouse - Item ID - Price - Item ID - Name - Description Marketing - Item ID - Inventory Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity - Item ID - Delivery Type Shipping
  26. 26. @mauroservienti | #EDDD - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity Warehouse shopping cart [ list-of ] - Item ID - Quantity - Name - Description - Delivery Est. Shopping Cart [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  27. 27. @mauroservienti | #EDDD Shipping shopping cart [ list-of ] - Item ID - Quantity - Name - Description Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  28. 28. @mauroservienti | #EDDD Marketing tends to be stable [ list-of ] - Item ID - Quantity Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  29. 29. @mauroservienti | #EDDD Do we need the Shopping Cart at all? [ list-of ] - Item ID - Quantity Shopping Cart [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  30. 30. @mauroservienti | #EDDD Can Sales be responsible for that concept? [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  31. 31. @mauroservienti | #EDDD We followed the coupling [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  32. 32. @mauroservienti | #EDDD information structure doesn’t fit users
  33. 33. @mauroservienti | #EDDD Can Read/View Models be a solution? Marketing Sales Shipping Warehouse others ViewModel Storage Shopping Cart
  34. 34. @mauroservienti | #EDDD that’s a cache
  35. 35. @mauroservienti | #EDDD We cannot cache everything
  36. 36. @mauroservienti | #EDDD Shared identifiers [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  37. 37. @mauroservienti | #EDDD ViewModel Composition /products/ Browser 1
  38. 38. @mauroservienti | #EDDD ViewModel Composition /products/ Marketing Sales Shipping Warehouse others Browser IDIDIDIDID 1 ViewModel
  39. 39. @mauroservienti | #EDDD How can we build such a page?
  40. 40. @mauroservienti | #EDDD Sales Product Requests Handler
  41. 41. @mauroservienti | #EDDD Sales Request matching
  42. 42. @mauroservienti | #EDDD Sales Composition
  43. 43. @mauroservienti | #EDDD what about writes?
  44. 44. @mauroservienti | #EDDD ViewModel Decomposition [ list-of ] - Cart ID - Item ID - Quantity - Delivery Est. - Item ID - Price - Item ID - Name - Description Marketing Sales Cart ID [ list-of ] - Item ID - CurrentPrice - LastPrice - Quantity [ list-of ] - Cart ID - Item ID - Inventory - Quantity Warehouse - Item ID - Inventory - Item ID - Delivery Type Shipping
  45. 45. @mauroservienti | #EDDD ViewModel Decomposition POST -> /shopping-cart/ Browser { ItemID Quantity }
  46. 46. @mauroservienti | #EDDD ViewModel Decomposition POST -> /shopping-cart/ Browser Sales Shipping Warehouse ID Q.ty ID Q.ty ID Q.ty { ItemID Quantity }
  47. 47. @mauroservienti | #EDDD Shipping Shopping Cart Requests Handler
  48. 48. @mauroservienti | #EDDD Shipping Request Matching
  49. 49. @mauroservienti | #EDDD Shipping Decomposition
  50. 50. @mauroservienti | #EDDD things might go wrong
  51. 51. @mauroservienti | #EDDD Shipping Decomposition
  52. 52. @mauroservienti | #EDDD Shipping Shopping Cart Requests Handler
  53. 53. @mauroservienti | #EDDD Shipping Error Handling
  54. 54. @mauroservienti | #EDDD Append Only Model
  55. 55. @mauroservienti | #EDDD there is no such thing as orchestration
  56. 56. @mauroservienti | #EDDD Full Vertical Slices MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition
  57. 57. @mauroservienti | #EDDD services need to communicate
  58. 58. @mauroservienti | #EDDD Business requirements (#4) • Annoy Notify users of 1 week stale carts • Wipe 1 month stale carts
  59. 59. @mauroservienti | #EDDD Services communication channel MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition
  60. 60. @mauroservienti | #EDDD Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart
  61. 61. @mauroservienti | #EDDD Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout
  62. 62. @mauroservienti | #EDDD Services communication channel MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout
  63. 63. @mauroservienti | #EDDD 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout Cart Got Stale
  64. 64. @mauroservienti | #EDDD 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout busCart Got Stale
  65. 65. @mauroservienti | #EDDD 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Cart Got Stale
  66. 66. @mauroservienti | #EDDD 1 week later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & data behavior & data ViewModel Composition ViewModel Composition ViewModel Composition ViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Notify User Cart Got Stale
  67. 67. @mauroservienti | #EDDD 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Cart Expired
  68. 68. @mauroservienti | #EDDD busCart Expired 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout Cart Expired
  69. 69. @mauroservienti | #EDDD 1 month later MarketingSales Warehouse Shipping behavior & data behavior & data behavior & databehavior & data ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout busCart Expired Cart Expired
  70. 70. @mauroservienti | #EDDD 1 month later MarketingSales Warehouse Shipping behavior & databehavior & data behavior & data behavior & data ViewModel Composition ViewModel Composition ViewModel Composition ViewModel Composition Add Item to Cart 1. Set 1 week timeout 2. Set 1 month timeout bus Wipe cart Wipe cart Cart Expired Cart Expired
  71. 71. @mauroservienti | #EDDD cross services events can be as thin as event name and identifiers
  72. 72. @mauroservienti | #EDDD bus The final big picture MarketingSales Warehouse Shipping behavior & databehavior & data behavior & databehavior & data UI Shell ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition
  73. 73. @mauroservienti | #EDDD the 45’ tyranny Demos bit.ly/explore-ddd-demos Udi Dahan talking about boundaries go.particular.net/explore-ddd-boundaries
  74. 74. @mauroservienti | #EDDD Takeaways • Boundaries are key to success • Do not bring in more technology to solve non- technical problems
  75. 75. @mauroservienti | #EDDD Takeaways • Boundaries are key to success • Mental model can badly influence design • Users/Business analysts tend to think in term of data presentation
  76. 76. @mauroservienti | #EDDD Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Premature names stick and drive data aggregation
  77. 77. @mauroservienti | #EDDD Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Behaviors define how to aggregate data • Group data that change together and that influence each other • Use anti-requirements techniques to validate data grouping • Follow the coupling
  78. 78. @mauroservienti | #EDDD Takeaways • Boundaries are key to success • Mental model can badly influence design • Do not name things prematurely • Behaviors define how to aggregate data • Use ViewModel composition to present data • No need for complex projections and read models
  79. 79. @mauroservienti | #EDDD Thank you! I’ll be around to answer your questions the whole day
  • patrickgiry

    Feb. 27, 2020
  • ashithmr

    Dec. 8, 2018
  • rajrao2

    Sep. 21, 2018
  • dmannock

    Sep. 19, 2018
  • xavierfolch

    Sep. 19, 2018
  • ChrisMorgan8

    Sep. 18, 2018
  • MauroLeal1

    Sep. 18, 2018
  • oguz4n

    Sep. 15, 2018

It always starts well. At first glance the requirements seem straightforward, and implementation proceeds without hiccups. Then the requirements start to get more complex, and you find yourself in a predicament, introducing technical shortcuts that smell for the sake of delivering the new feature on schedule. In this talk, we'll analyze what appears to be a straightforward e-commerce shopping cart. We'll then go ahead and add a few more use-cases that make it more complex and see how it can negatively impact the overall design. Finally, we'll focus our attention to the business needs of these requirements and see how it can shed light on the correct approach to designing the feature. Walk away with a new understanding on how to take requirements apart to build the right software.

Views

Total views

1,303

On Slideshare

0

From embeds

0

Number of embeds

81

Actions

Downloads

12

Shares

0

Comments

0

Likes

8

×