You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From looking at your guide I am struggling to find a good approach on how to use interfaces to use cross domain models.
If we take a Book and Author example, where these are separate domains. If we have an api endpoint that lists all the books in the system and as part of the data we want to return the authors name. How would we do this without having to make a request to the Author interface for each book that exists to get its details. As this could cause alot of requests to the database i.e. 1 query for the list of books + x number of queries for each books author.
This problem would become more prominent if the different domains live on separate hosts.
What is the approach you take? I have seen you have mentioned having a UserSerializer in the domain for its context (which makes sense), but how would you pass your data between the two domains?
Hello!
This is a good question, and I've dealt with a similar issue like this before, where we wanted some information usually stored in Domain B, but we wanted it regularly in Domain A.
Keep in mind that the Books/Authors example is probably a bad one for this case, because for a Human's perspective it makes sense to keep those models together.
Remember that a Domain should store information that is relevant to it, ideally within it's own Domain. Definitely if it is information you need a lot, such as the Author's name. So in your example I would see keep a copy of the Author's name in the models in the Book's Domain. This is duplicate information yes, and you'd need to keep the two Domains in sync, which is no different from the usual strategy we'd take if we had two distinct domains that needed to keep a shadow model in sync.
See this bounded context example where they are duplicating information at the boundaries of two domains, because it is cheaper to keep them in sync than to make more expensive cross-domain queries often.
From looking at your guide I am struggling to find a good approach on how to use interfaces to use cross domain models.
If we take a Book and Author example, where these are separate domains. If we have an api endpoint that lists all the books in the system and as part of the data we want to return the authors name. How would we do this without having to make a request to the Author interface for each book that exists to get its details. As this could cause alot of requests to the database i.e. 1 query for the list of books + x number of queries for each books author.
This problem would become more prominent if the different domains live on separate hosts.
What is the approach you take? I have seen you have mentioned having a UserSerializer in the domain for its context (which makes sense), but how would you pass your data between the two domains?
Thanks
#12
The text was updated successfully, but these errors were encountered: