Hi Jan.
Guess what .. I am reading "Dependency Injection" (Dhanji R. Prasanna)
at this moment :)
So this was one of the things why I doubt my design. But I really do
not understand how DI (GIN) should
be applied in my case:
- A Presenter uses several Views. The view depends on the
authorization (implemented as enum). Now I do something like:
switch (authorization) {
case A:
view = new View(fieldSpecA);
break;
case B:
// etc
}
Regards,
Ronald
On 25 jan, 17:18, Jan Ehrhardt <[email protected]> wrote:
> The reason, why another class creats both and than puts the view into the
> presenter is called Dependency Injection. It is a widely used pattern, that
> means that you should inject dependencies into classes instead of using
> factories or doing something like 'new DependentClass()' in the constructor.
> In the best case, your presenter refers to a view interface and gets its
> view implementation injected.
>
> The easiest way of doing Dependency Injection in GWT is GIN
> (http://code.google.com/p/google-gin). It allows you to configure
> dependencies and let GIN do the creation of objects and put one into another
> at runtime.
>
> Dependency Inection is one of the best practices in GWT (and Java too)
> development (http://www.youtube.com/watch?v=PDuhR18-EdM)
>
> Regards
> Jan Ehrhardt
>
>
>
> On Mon, Jan 25, 2010 at 2:54 PM, rmuller <[email protected]> wrote:
> > Should not the Presenter create the view?
> > Sometimes you need different views (based on authorization data in my
> > case) where you can reuse the Presenter. I let the Presenter decide
> > which view to use. I do this in the ctor.
> > In all examples I see however, the Presenter and View are created by
> > the parent Presenter/AppContext. Also every View has its own Presenter
> > (1 : 1). So I wonder if my design is correct.
>
> > What is the general opinion about this?
>
> > Ronald
>
> > --
> > 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]<google-web-toolkit%2Bunsubs
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
--
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.