RE: Returning newly created entities from the aggregate
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
Sorry about my previous message, it seems that I can't just use reply from my mail client ;( I think there are several conflicting issues here. 1) I think mutating object during command is perfectly fine. In HTTP terminology this would mean that you can return the same object (or reference to it) as a result. This would require you to use synchronous domain events. 2) Static domain event handlers are evil, especially if you are working with a database, since they lack notion of transactions. 3) Pooling and other ways of obtaining newly created value are just complicating the design for no benefit. 4) If your DB layer works in lazy mode, this creates a set of it's own problems. So, I would implement it as a domain event, which gets ID populated on the server and returns its modified instance to the client. Regards, Rikard