Re: Aggregate root, factory method and entity as a result
Mauro Servienti <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
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 > > > ------------------------------------ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/domaindrivendesign/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/domaindrivendesign/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/