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.
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. @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
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. @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. @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. @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. @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. @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. @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…
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…
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. @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. @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. @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. @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. @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. @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
59. @mauroservienti | #EDDD
Services communication channel
MarketingSales Warehouse Shipping
behavior & databehavior & data behavior & databehavior & data
ViewModel Composition ViewModel Composition ViewModel CompositionViewModel Composition
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. @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. @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. @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. @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. @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. @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. @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. @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. @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. @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
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. @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. @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. @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
I’m a remote worker
We live in a small flat, thus I have a small office
I enjoy going to the office by bike
And I enjoy bananas for my breaks
Bike riding and bananas in the backpack are not a great idea, so…
How is this thing designed?
I’m a remote worker
I enjoy going to work by bike
And I enjoy bananas as lunch breaks
Bike riding and bananas in the backpack are not a great idea, so…
Price cannot unexpectedly change while an item is in the cart
Price cannot unexpectedly change while an item is in the cart
we could have shipping that kicks in to define shipping policies, and so on.
distributed monolith
Distributed monolith
The least amount of coupling
Sales conceptually own the shopping car concept
Sales conceptually own the shopping car concept
Sales conceptually own the shopping car concept
Sales conceptually own the shopping car concept
Since we have very low, if not zero, coupling across services.