Re: RE: How to generally decide between FACTORY and constructor?
Szymon Pobiega <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAEPUun9PMVnSEKkFvw3vTiaaXh5GecMcJFHk9GLLLhwX7dxUhw@mail.gmail.com> |
Yeah, I missed this one. Although I think more common example would be var tenant = repo.GetById(tenantId) var user = tenant.RegisterUser(<some user info>) Totally forgot that RegisterUser would technically be a factory method here:) Szymon 2014-02-14 20:37 GMT+01:00 Tomasz Jaskula <[email protected]>: > > > Having a factory method on a AR or Entity which creates another AR is > quite common scenario. Something like : > > var user = Tenant.RegisterUser(<some user info>) > > It depends on the UL and what are you trying to say... > > Thomas > > > Le 14 févr. 2014 à 20:27, Szymon Pobiega <[email protected]> a > écrit : > > > Personally I haven't seen a case where you would need a factory or factory > method for AR or Entity. Regarding VOs, factories and factory methods > allows to better capture the language e.g. instead of var er = new > ExchangeRate(x, y) i would use var er = ExchangeRate.Between(x,y) or > something like this. > > Szymon > > > 2014-02-14 19:56 GMT+01:00 <[email protected]>: > >> >> >> There's a choice between factory method, static class factory method, an >> explicit factory instance, abstract factory, ... choose wisely. >> > > > > >