Let's not forget easier AOP, scope and component lifecycle. Which reduces an enormous lot of error-prone boilerplate. Dhanji.
On Fri, Sep 12, 2008 at 12:58 PM, Eric Anderson <[EMAIL PROTECTED]>wrote: > > On Thu, Sep 11, 2008 at 7:44 PM, Sam Berlin <[EMAIL PROTECTED]> wrote: > > ... if you do this through non-hand-coded DI then the > > objects are constructed for you with only the dependencies they > > directly need to have. > > In fact, this is the reason our team uses Guice heavily. A class need > only be provided with its immediate dependencies. A class that gets > injected with something, only so that it can be passed off for another > class to use, is noisy at best, and completely confusing at worst. > When you pass in extra dependencies, you create noise in both the > production code and the test code. > > Another point of interest is, using an IoC container like Guice, > allows you to pull in dependencies easily. For instance, my team > writes long-running applications for dealing with data feeds. One > business requirement is that we periodically report what point the > process is at so that monitors make decisions about whether the > overall system is healthy. As we determine what parts of the process > need to do update (because they are slow) and what parts should not > update (because they are fast and would simply create noise), those > slow classes need to be fed the StatusReporter instance. And, unit > tests are written to express the business rules and ensure that a > particular class is properly reporting status. Since the > StatusReporter interface is bound up in the Guice modules already, it > is dead simple to add status reporting to any existing class. All it > takes is, changing the constructor of a single class, and tweaking the > unit tests for that class. No other classes care that I've changed > that constructor. Zero other production classes change. > > IoC containers allow a much more decoupled system so that change is > very isolated. > > Eric > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
