Actually, I'd be surprised if the dependancy injection implementation
doesn't boil down to a form of deferred binding in the end for performance
reasons (except using the Generators mechanism instead of explicit deferred
binding).

On Tue, Apr 14, 2009 at 5:24 AM, Thomas Broyer <[email protected]> wrote:

>
>
>
> On 10 avr, 17:52, Yves <[email protected]> wrote:
> > Hello
> >
> > Reading the documentation for the module xml files, i just realize
> > that the tag <replace-with .../> allows for dependency injection.
>
> How that?!
>
> > Suppose i need to use different class implementation depending on my
> > environment (real class for production, mock for development ...). I
> > just have to have two (or more) module xml like this
> >
> > For production use file FooProd.gwt.xml
> >
> > <module>
> >   <replace-with class="foo.FooProdImpl">
> >     <when-type-is class="foo.Foo" />
> >   </replace-with>
> >   ...
> >
> > For development use file FooDev.gwt.xml
> >
> > <module>
> >   <replace-with class="foo.FooMockImpl">
> >     <when-type-is class="foo.Foo" />
> >   </replace-with>
> >   ...
> >
> > Am i wrong?
>
> Yes, that's not dependency injection, it's just deferred binding.
> This is not *injecting* anything, you still have to instantiate your
> class explicitly with a GWT.create(...) call somewhere in your code
> (you don't say at that point which specific implementation will be
> used, but that has nothing to do with dependencies nor injection). If
> one of your classes gains a dependency on another interface, you'll
> have to inject that new dependency at each and every instantiation
> point.
>
> In summary: deferred binding has nothing to do with dependency
> injection. Deferred binding is very handy, but it's just something
> else (and a DI framework for GWT *must* IMO support deferred bindings,
> but all of them, from Suco to GIN, support it AFAICT).
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to