What is the benefit to do it via the repository, when it only delegates to the factory anyway?
In DDD book it is described that Repository and Factory have different responsibilities. We could sure do it through delegation via repository, if it simplifies or makes things more beautiful, but I'm not totally convinced that it will. Note that the factories also are used by abstract controller classes in the framework also. If done via repository we must introduce some repository interface with the create method in the framework also. /Patrik Steffen Stundzig wrote: > > Hi, > > what Do you think about a single point of rich object creation in the > appropriate object repository like: > > RichPersonRepositoryImplBase: > > public RichPerson createFrom(Person domain) { > RichPerson richPerson = richPersonFactory.create(); > richPerson.fromModel(domain); > return richPerson; > } > > So we have one single method to create objects, which could be used > e.g. from RichPersonRepositoryImpl to transform person objects retrieved > from other PersonService methods without the need to get/inject the > personFactory. > > In the referenced rich objects, which contains reference holder like: > > public RichPerson getCaller() { > if (callerHolder != null) { > return callerHolder.get(); > } > > populate(); > callerHolder = new AtomicReference<RichPerson>(); > if (populated != null) { > if (populated.getCaller() != null) { > callerHolder.set(richCallerFactory.create()); > callerHolder.get().fromModel(populated.getCaller()); > } > } > return callerHolder.get(); > } > > this could be changed to call the createFromModel()-method. Therefore we > must inject repositories into other repositories, which is more > symmetric to the backend stuff. > > What do you think of it? > > regards > > ------------------------------------------------------------------------------ > Check out the new SourceForge.net Marketplace. > It is the best place to buy or sell services for > just about anything Open Source. > http://p.sf.net/sfu/Xq1LFB > _______________________________________________ > Fornax-developer mailing list > Fornax-developer@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/fornax-developer > > -- View this message in context: http://www.nabble.com/-sculptor--RichXXX-RichXXXRepository.createFromModel%28XXX-xxx%29-tp21385810s17564p21387683.html Sent from the Fornax-Platform mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Fornax-developer mailing list Fornax-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fornax-developer