Mauro Servienti - Talk Session: All Our Aggregates Are Wrong
Why Stack Overflow recommends it
Stack Overflow users link it when discussing aggregate boundaries, bounded contexts, and composing UI or view models across microservices in DDD designs.
Recommended by 3 people across 5 different months, 2019 to 2021.
What it is
A conference talk from Explore DDD 2018 by Mauro Servienti of Particular Software. It walks through a seemingly simple e-commerce shopping cart, shows how added use cases distort the aggregate design, and then uses the underlying business needs to find a better decomposition.
What people said
Recommends choquero70 · 2019-02 · Stack Overflow · on “Design Ecommerce Microservices”
It seems that what you need is to show in a view info coming from different microservices (contexts). You can use ViewModel Composition technic, where an infraestructure component (a request handler) intercepts the http request and allows microservices to participate in the response, looking for a microservice who says "hey, I have that info" (Inventory has the info about stock, Pricing about price, and so on). This infraestructure component compose a dynamic viewmodel on the fly, with the info coming from differect microservices. I've never implemented it, but look at this video explaining it, from minute 17:35 to 21:00 [this video] Hope it helps.
Recommends VoiceOfUnreason · 2019-06 · Stack Overflow · on “Aggregate root invariant enforcement with application quotas”
I'm pretty sure that this is a common scenario that must have a better way to be implemented that my previous examples. A common search term for this sort of problem: Set Validation [LINK] . If there is some invariant that must always be satisfied for an entire set, then that entire set is going to have to be part of the "same" aggregate. Often, the invariant itself is the bit that you want to push on; does the business need this constraint strictly enforced, or is it more appropriate to loosely enforce the constraint and charge a fee when the customer exceeds its contracted limits? With multiple sets -- each set needs to be part of an aggregate, but they don't necessarily need to be part of
Recommends VoiceOfUnreason · 2019-10 · Stack Overflow · on “DDD: How many aggregates should have a single bounded context?”
How many aggregates should have a single bounded context? All aggregates should have a single bounded context. You can almost work that out backwards - an aggregate is going to be stored in a single database, a database is going to belong to a single (micro) service, a service is going to serve a single bounded context; therefore it follows that an aggregate is going to belong to a single bounded context. Where things can get messy: it's easy to take some broad business concept, like "order", and try to create a single representation for order that works for every bounded context. That's not the goal though -- the goal is for each context to have a representation of order that works in that
Recommends VoiceOfUnreason · 2020-05 · Stack Overflow · on “Populate aggregate root from multiple databases”
I am a beginner in DDD and would like to understand if it is a bad practice to try to populate a single aggregate root from multiple database ? Yes. The happy path isn't the expensive one. Reads aren't necessarily an issue; if all you are doing is producing a report, pulling data from multiple sources is fine (although we of course recognize that those sources might not be "consistent" with each other. But trying to manage writes with two databases, it becomes difficult to ensure the integrity of your data when things start going wrong - a crash in the middle of your update does not leave your data in a healthy state. The good news? If the data is already spread across two databases, it is l
Recommends VoiceOfUnreason · 2020-05 · Stack Overflow · on “DDD aggregate design example with a many-to-many relationship”
I don't think you are going to find an authoritative answer to your question that is more specific than "it depends". For instance - suppose the game was chess, and we want to award an achievement when a player has one at least once with each color. That's not going to be the responsibility of a "game" aggregate; we can see that immediately from the fact that the life cycles don't line up. One quick way to sketch this suggests that we might have games raising "domain events" to announce wins, and then a little state machine that uses wins as inputs an announces awards, and then some report that lists all awards for a specific player id. The state machine, and the accompanying domain logic th
Recommends VoiceOfUnreason · 2020-05 · Stack Overflow · on “DDD - Relaxing the rule of Eventual Consistency between aggregate”
Do you think that this is a special case that the book mentions? No. What I suspect you have here is a modeling error. From your description, it sounds like you are dealing with something like a CellAssignment , and the invariant that you are trying to maintain is to ensure that there are no conflicts among active cell assignments. That suggests to me that you are missing some sort of aggregate - something like a seating chart? - that keeps track of all of the active assignments and conflicts. How can you know? One way is to graph your aggregates; create a node for each piece of information you need to save, and join nodes with lines if there is a rule that requires locking both nodes. If yo
Recommends Valentin Gerbey · 2021-09 · Stack Overflow · on “Problem with DDD and changing only one Aggegate in one transaction”
You should understand do you really need transactional consistency between your statuses, maybe eventual consistency will be a solution and you will update statuses by events. In case it requires transactional consistency then it must be one aggregate because this is the main feature of aggregate to protect true invariants. To find an answer to the question you need to ask the business about this in a real project. The important thing is true invariants, in your example, I think, you have entity-oriented aggregates, but you need more policy or process-oriented aggregates with capability is only to protect true invariants rather than being data containers. Maybe this video will be helpful Mau
Cites VoiceOfUnreason · 2020-08 · Stack Overflow · on “Validation of domain rules spanning multiple aggregate roots”
Now, the problem that I'm facing is - how do I correctly and efficiently enforce this? Aggregates 101: if you have two pieces of information that must be in agreement at all instants, then those two pieces of information should be part of the same aggregate, because any transaction that might change one must also take into account the other. Two pieces of information that must agree when the system is in equilibrium, but not necessarily while things are changing, can be distributed across two different aggregates. So that's the first piece that you have to work out - do your appointments need to be consistent with the service state always? or just when things stop moving? (In most cases invo
Cites VoiceOfUnreason · 2020-09 · Stack Overflow · on “How to handle hard aggregate-wide constraints in DDD/CQRS?”
The search term you are looking for is set-validation [LINK] . Relational databases are really good at domain agnostic set validation, if you can fit the entire set into a single database. But, that comes with a cost; designing your model that way restricts your options on what sorts of data storage you can use as your book of record, and it splits your "domain logic" into two different pieces. Another common choice is to ignore the conflicts when you are running your domain logic (after all, what is the business value of this constraint?) but to instead monitor the persisted data looking for potential conflicts and escalate to a human being if there seems to be a problem. You can combine th
Cites Matster2 · 2021-03 · Stack Overflow · on “DDD UI composition across multiple contexts on creation”
Based on this talk from Mauro Servienti called "All Our Aggregates are Wrong. Here is the link for reference: [this video] We might have a few bounded contexts each containing information of a item. e.g Marketing Context - name, description, images Sales Context - list price, product code? Inventory - stock level Each context might have their own name for it, e.g. inventory might call it sales item. I think sales might be the owner of an item so when you go to create an item that is the place it will be created. I have two questions. Does the UI call these context's seperately? If I have a UI to create a product/item and takes the data for both marketing and sales (list price, product code, name,