Timeline for Where should an object in CQRS+ES be fully initialized: in the constructor, or when applying the first event?
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 12, 2014 at 8:13 | comment | added | Andrea | I understand better the question. So, I would say, the correct answer should be the third one. I think your entities should always be in a valid state. If this requires that a shopping cart has a customer id, then this should be provided at creation time, hence the need of a constructor that accepts a customer id. I am more accustomed to CQRS in Scala, where domain objects would be represented by case classes, which are immutable and have constructors for all possible combinations of parameters, so I was giving this for granted | |
Aug 11, 2014 at 13:49 | comment | added | stakx |
My question is not about how to model the domain; I'm deliberately using a simple (but perhaps imperfect) domain model for the sake of asking a question. Take a look at the CreatedEmptyShoppingCart event in my question: It has the customer info, just like you suggest. My question is more about how such an event relates to, or competes with, the class constructor of ShoppingCart during implementation.
|
|
May 15, 2014 at 16:06 | history | answered | Andrea | CC BY-SA 3.0 |