You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 2Just to point out: the added difficulty here is that you have a secret link between your different domain aggregates. If you load Tom as a person (which includes their friend list), and you also load Andy (which includes their friend list), and Tom now adds Andy as a friend, that means that you're expecting Andy's list to update and suddenly also contain Tom. This is not something you will find prescribed in general DDD documentation as it is a very special case. I haven't had the time to investigate for a full answer but I suspect that you will need to make friendships have their own context.Flater– Flater2023-09-08 03:02:10 +00:00Commented Sep 8, 2023 at 3:02
- Well it's a made up situation, I mostly tried to come up with the simplest example. The question isn't about this specific scenario but more about how to deal with the fact that objects will always be partially loaded and the domain layer needs to be in sync with the infrastructure layer in order to avoid errorMyUsername112358– MyUsername1123582023-09-08 04:01:15 +00:00Commented Sep 8, 2023 at 4:01
- 1The point I was getting at is that this is a problem of your own making, this is a nested structure that is very likely an infinite one (to the point of exhaustion of having loaded all your users). You don't want this, but you also don't want any of the additional work that the alternatives present. Something's gotta give, and we can't decide which poison is best to pick. There are myriad ways of modeling this and I'm not convinced that the current question is focused enough towards a particular approach. Every approach has wildly different pros and cons and this requires more analysis.Flater– Flater2023-09-08 05:22:32 +00:00Commented Sep 8, 2023 at 5:22
- 2What I have found that helps is not holding the whole objects, just the ids. Ask yourself why you actually need to describe your domain entity with all the friends' objects. Where exactly does your BL use it? is it common or do you only use it occasionally? Your User entity has friends, ok, but what if the entity itself will hold only the ids of the friends?oren– oren2023-09-08 10:25:40 +00:00Commented Sep 8, 2023 at 10:25
- 1I almost exclusively use the domain layer for write operations, and yes I'm already implementing the CQRS pattern but I don't see how that is relevant to how I design my domain layer?MyUsername112358– MyUsername1123582023-09-12 17:40:56 +00:00Commented Sep 12, 2023 at 17:40
| Show 6 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-cs