Hi Fred, Jayr, thanks for your answers. I see. I watched the google-guice presentation on YouTube and I guess I read too much into the "guice eliminates the need for factories" parts. I thought that perhaps there was some kind of command pattern for injectors somewhere that I was overlooking.
Regards On Thu, Apr 7, 2011 at 10:54 PM, jMotta <[email protected]> wrote: > Complementing what Fred said, > > You can still use your factories while using Guice, they dont exclude each > other. Using Guice in addition with your factories you'll add inversion of > control to your software, and the consequences of it you already know. > > These desired side-effects caused by you factories can still be used > through http://code.google.com/p/google-guice/wiki/ProviderBindings and > you can bound the implementations provided by this class to a given > interface inside your module. And if you want to change the implementation > in the future you must just change the code of the provider or the provider > itself. :) > > Atenciosamente, > > *Jayr Motta* > Software Developer > * > * > I'm on > BlackBeltFactory.com<http://www.blackbeltfactory.com/ui#%21User/jmotta/ref=jmotta> > ! > > > > On Thu, Apr 7, 2011 at 4:56 PM, Fred Faber <[email protected]> wrote: > >> The Factory that you describe is a domain-level entity, in that it is >> performing more work than simply object instantiation. >> >> You may retain use of such factories and incorporate Guice: the two are >> certainly not mutually exclusive. >> >> The merge step is to ensure you use Guice and not "new" when your factory >> creates instance of a class. To do this, inject a Provider<> into your >> Factory, or otherwise return an injected instance. >> >> Fred >> >> >> On Thu, Apr 7, 2011 at 3:22 PM, Tristan de Inés < >> [email protected]> wrote: >> >>> Hi there, >>> >>> I believe that one of the main uses of factories besides dependency >>> management, decoupling the interface from the implementation, and >>> instance configuration is running "extra code" whenever a new instance >>> is requested. What if I want to notify listeners, make sure all new >>> instances are put into a certain collection, have some log output, >>> etc, on every instance request to a factory? "Side effects" like these >>> are easily accomplished inside factory methods. I see what google- >>> guice does for me, but I may be overlooking something, because I'm not >>> sure how I would go about replacing my factory-heavy dependency >>> management with google-guice without sacrificing the flexibility of >>> these "side-effects" in my factory methods. >>> >>> Is this a conscious limitation of google-guice or a design issue on my >>> part? Input appreciated. >>> >>> Regards >>> >>> -- >>> 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. >>> >>> >> -- >> 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. >> > > -- 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.
