Timeline for Proper way to interact with child entities through aggregate root
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 10, 2022 at 15:50 | history | edited | VoiceOfUnreason | CC BY-SA 4.0 |
added 13 characters in body
|
| Jul 11, 2021 at 9:57 | comment | added | Laiv | Bubbling up events within an aggregate root is, in most of the cases, unnecessary complexity. Root has enough scope and knowledge to know what to do when children changes. One more drawback could be that eventual communication via events might end in race conditions. Something relatively easy to avoid with Observer pattern, which in my opinion is also unnecessary here. | |
| Jul 10, 2021 at 4:03 | comment | added | thomas_p | To sum up, what I keep from your answer is that I should stick doing any "calculations" involving a chlild entity directly in the aggregate root's methods and use Domain Events mostly for cross-aggregare communication. Thank you once again. | |
| Jul 10, 2021 at 4:03 | comment | added | thomas_p | Thank you very much for taking the time to read my question and reply. Indeed the code in my examples is not the "prettiest" since I am not quite familiar with C# or LINQ yet. Also encapsulating some logic in methods, like Find() in your example, is a good idea, since I can reuse it and it also embraces the DRY principle. FInally, I 've read that Domain Events are primarily used to propagate changes between different aggegates, but after reading this: shorturl.at/ivEU9 it seemed to me like suitable use of Domain Events as I wanted the changes in the aggregate to propagate from "botom to top". | |
| Jul 10, 2021 at 3:31 | history | answered | VoiceOfUnreason | CC BY-SA 4.0 |