Re: Aggregate root, factory method and entity as a result
Chris Bingham <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAKESE8vjucgt4J2Fco0v7qSw2yo_vYwMAut9ucNya3Mbm+GDRA@mail.gmail.com> |
quick and dirty gist of state machine and user constructor - https://gist.github.com/donbing/9429867 and by property/reference, i meant something like your Members collection... On 8 March 2014 07:03, Mauro Servienti <[email protected]> wrote: > > > Why not as simple as put, if you are using C# or a language that supports > members visibility, Tenant and User in the same assembly and define the > User constructor as internal? > > .m > -- > (no keyboard keys have been killed due to the really annoying OSX spell > checker) > > > On 07/mar/2014, at 19:39, Dariusz Lenartowicz < > [email protected]> wrote: > > > Hi, > > I'm looking for some advice. > > > > Suppouse I have Tenant AR which can create User entity (User is not AR > > within this particular context), so code can looks like this: > > > > var tenantId = sessionContextService.TenantId; > > var tenant = tenantRepo.Get(tenantId); > > var user = tenant.CreateUser(username, password); // there I can > > validate invariants > > userRepo.Add(user); > > > > To achive this User class should have public ctor: > > > > public User(Tenant tenant, string username, string password) > > > > but nobody prevent me to do this: > > > > var tenantId = sessionContextService.TenantId; > > var tenant = tenantRepo.Get(tenantId); > > var user = new User(tenant, username, password); > > userRepo.Add(user); > > > > How to force creation of User entity through CreateUser method on tenant > > AR? > > Is it only matter of discipline or there are some solutions for that > > situations? > > > > Best regards > > Darek > > > > > > > > > > ------------------------------------ > > > > Yahoo Groups Links > > > > > > > > >