RE: Returning newly created entities from the aggregate

<[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <[email protected]>
Hi Moran,
 

 I was planning to use domain events for other aspects of this system but I hadn't considered using them for this purpose, it certainly makes sense though, thank you.
 

 Thinking about this from an implementation point of view I think the most fitting route would be to return the ID from the method for the time being.
 This is running in a web application so bringing events into the mix here might complicate things unnecessarily.
 

 Psuedocode:
 

 parent = GetOrganisation(parentId)
 new_id = null;
 SubscribeToOrganisationCreatedEvent(ev => new_id = ev.new_id)
 parent.RegisterSubOrganisation("alpha bravo")
 RedirectToOrganisationPage(new_id)
 

 versus
 

 parent = GetOrganisation(parentId)
 new_id = parent.RegisterSubOrganisation("alpha bravo")
 RedirectToOrganisationPage(new_id)
 

 

 Having typed that out it only adds 2 lines really so I shall have to give this some more thought.
 

 

 Regards,
 Matt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.