Re: RE: Returning newly created entities from the aggregate
Rikard Pavelic <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 15.12.2013. 16:55, [email protected] wrote: > > > Hi Ramin, > > > The ID for the sub organisation isn't created until it is persisted to the database unfortunately. And in writing this I've just realised I can't just return the ID from the method for that same reason. > > > I'm not sure I understand what you mean with regards to the polling technique. Are you suggesting that I could poll to retrieve the result of the command and retrieve the ID that way? Would that not be similar to just returning a value from the command in the first place? > > > 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 instance to the client. Regards, Rikard - -- Rikard Pavelic https://dsl-platform.com/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSrpP+AAoJELBms/fUcNQT87QH/Ak3JNEjA+CD6hEcnYZqnAaR SQ6TNDwnJ6C1sfq+Cf83iLsPy6b6c2JwPHuCV0aHPMp/e7UUzXr9Ekrx3O2O8UPf LUwHol0G1Cqh4yf49deLLdij7pzjJvGC8lvzLMdvP1i6oYYB30DAAY183Cus89Zw h7QhdKQhYT5a4fxYx6DWkxpMbtXU8PwGIpZkYBIlGCrxbaTKmLBhuMoyeovg3HXs 1pj9Fq3oktWQwiEALLnhmpNMt4BmWmOxI9dD3igv0JmclF1HZ6lZDpahiyjcGOpf VwyXmMiNQyD1rn8isvv4p4Rrt0y0UXielGAaPcVh09uKENr1a6lod99ZwymJIm0= =nBUb -----END PGP SIGNATURE-----