+1, generally speaking. I think people sometimes get into this because D-I systems are a bit like meta-factories, and with assisted injection and providers, you can do factory-like things. But it creates really tempting paths that lead to scoping problems. In general, I like to keep value objects and services quite separate, and Entities (managed value objects) should be managed by a service, not by the Injector.
cheers, Christian. On Oct 28, 2009, at 7:39 PM, Haulyn R. Jason wrote: > > Hi, just create a factory and use Guice to inject it. But I do not > think it's a good idea to add Service or Repository to Domains. You > may want to implement Evans DDD, but please check this > :http://www.udidahan.com/2008/02/29/how-to-create-fully-encapsulated-domain-models/ > > If it is possible, do not add service or repository to Domains. > > > > On Wed, Oct 28, 2009 at 4:41 AM, Brian Pontarelli <[email protected] > > wrote: >> >> You could abstract out the domain creation and then post inject using >> the injectInstance method (I think that is what it is called). >> >> -bp >> >> >> On Oct 27, 2009, at 2:14 PM, Jo Vanthournout wrote: >> >>> >>> I was wondering whether guice has a way of injecting domain services >>> in domain objects. >>> >>> This is particularly handy when using domain driven design. This >>> way, >>> domain objects themselves can be responsible for retrieving related >>> data and objects, which in turn results in better division of >>> responsibilities which results in a better OO design. All business >>> logic can be placed in the domain object (where it belongs) and the >>> need for rather artificial services that contain hidden business >>> logic >>> is minimized. >>> >>> The problem here is that domain objects (entities and value >>> objects as >>> they are called in domain driven design) are mostly constructed via >>> the new operator. Typically they are created by a framework like >>> hibernate, which pools the data for the domain object from the >>> database. >>> >>> Spring provides this functionality via load time weaving in >>> combination with the @configurable annotation. All the calls to the >>> new operator of the domain objects that are defined in the >>> application >>> context are intercepted and the correct dependencies are injected. >>> >>> Thanks for the information >>> >>> Jo >>> Belgium >>> >>>> >> >> >>> >> > > > > -- > Many thanks! > > Haulyn Microproduction > > You can access me with the following ways: > Location: Shandong Jinan Shumagang 6H-8, 250000 > Mobile: +086-15864011231 > email: [email protected], [email protected] > website: http://haulynjason.net > gtalk: [email protected] > skype: saharabear > QQ: 378606292 > persional Twitter: http://twitter.com/saharabear > persional Linkedin: http://www.linkedin.com/in/haulyn > Haulyn Microproduction Twitter: http://twitter.com/haulynmp > > > Haulyn Jason > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
