Re: Sharing Aggregate Roots between Bounded Contexts
Greg Young <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAC9RQth3J4CJ_b90E4NPzsMpNFgLac4NKZ7B6CY=Tr57QANVKw@mail.gmail.com> |
Why not just make a call trydeductpointsforcstomer or get/remove points for customer to points management? Or better make them all raise events? On Monday, May 27, 2013, wonderfulworldofpingpong wrote: > ** > > > Paul, thanks for clarifying on the aggregates. > > Here is an example I'm talking about. You are going to a County fair. You > can pay cash and get points. With those points you can visit the game area, > food stalls, buy products etc... For example, you buy 100 points for $100. > You take the points to the game area and play poker. Then you go to the > food area and have some food. > > Every time you visit a section in the County fair, the staff will ask you > how many points you have. Getting to the DDD, we can consider the game area > as one BC, food management as one BC and products selling area as one BC. > The visitor is the same. All the BCs are concerned about only one thing, > that is how many points the visitor has. They are not concerned about his > name, address or how much money he has. As long as he has points, he can > visit that section. So, an entity called 'visitor' is the same for all the > BCs. The Repository to read the points from the datastore is also the same. > In this case, do you prefer to put that visitor in a shared kernel? > Probably not, the same visitor will be concern for the security BC which > needs his name, address and phone etc... > > Hope that explains a scenario of the topic we are talking about. > > --- In [email protected] <javascript:_e({}, 'cvml', > 'domaindrivendesign%40yahoogroups.com');>, Paul Rayner <paul@...> wrote: > > > > On Sun, May 26, 2013 at 5:29 PM, wonderfulworldofpingpong < > > varghese.pallathu@...> wrote: > > > > > ** > > > > > > > > > Thanks Paul. > > > > > > So, even though it causes code duplication but it is required that two > BCs > > > need to have it's own aggregates else it needs to be in a shared > kernel. Am > > > I right? > > > > > Right. Bounded contexts have different models. There is nothing to share, > > concept-wise. Start with the model. I get the sense you are thinking > > implementation-only. > > > > And avoid shared kernels, if you can. > > > > > > > > Is it okay to share the implementation of a repository? > > > > > Generally, no. Why would you want to do this, since it would couple two > > bounded contexts tightly together? I would need to see an example. > > > -- Le doute n'est pas une condition agréable, mais la certitude est absurde.