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.
