> > On Wed, Mar 25, 2009 at 12:41 PM, Brian Pontarelli <[email protected] > > wrote: > Someone still has to create the classes and wire everything > together. Duck-typing doesn't really help or hurt. > > That's no pain at all since everything is mockable in Ruby without > interfaces or constructor separation. You can even redefine classes > on the fly for test cases. The main point of dependency injection is > testability, the rest is... well, nice, but not really germane to > the the design pattern.
I don't think the main point of DI is testing. I think it is removing instantiation and coding to interfaces. This helps testing, but even if your system had zero tests you would still benefit from DI. I think dynamic languages could use and benefit from DI, but there are a number of tricky details because of a lack of type information. DI will probably mature on those platforms and look quite different than with static languages, but the idea is still the same. In fact, the ideals of DI are even more true in dynamic languages because everything is coded to interfaces via dynamic method-dispatching. A class defines an interface for its dependencies via the methods it invokes on them. Injecting any class that conforms to that interface should work well and nicely decouple the classes. Along those lines, I wrote a brief piece recently regarding inferred typing (dynamic interfaces). Feel free to check it out here: http://brian.pontarelli.com/2009/03/06/inferred-typing/ -bp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
