Hello Alexey
I would advise against classes whose sole purpose are to propagate
dependencies to other classes. You may be better off using the builder
pattern or simply injecting a Provider instead. IMO a builder is generally a
good solution to these kinds of problems.

Dhanji.

On Sun, Aug 30, 2009 at 1:34 PM, Alexey Kuznetsov <[email protected]> wrote:

>
> Hello Dhanji!
>
> > Also extremely evil suggestion that should never be followed:
> > public class MyFinalFieldInjectees {
> >   @Inject private final Dep dep = null;  //this will work
> very interesting! I have no idea that Guice can do such kind of
> magic :)
> And yes I wouldn't follow that way actualy I'm trying escape this.
>
> > In other words, use Logan's recommendation to redesign your classes so
> they
> > are smaller and more composable.
> I just have an idea to wrap my buch of dependencies into Support-like
> classes and thus I have a question whould be this code correct.
>
> All my dependencies are Singeltons.
>
> [pseudo-code]
> public class DepSupport1
> {
>  private final IDependency1 dep1;
>
>  @Inject
>  public DepSupport1(IDependency1 dep1)
>  {....}
> }
>
> public class DepSupport2 extends DepSupport1
> {
>  private final IDependency2 dep2;
>
>  @Inject
>  public DepSupport1(IDependency1 dep1, IDependency2 dep2)
>  { super(dep1);
>   ....}
> }
>
> public class ClientClass1
> {
>  private final DepSupport1 ds1;
>
>  @Inject
>  public ClientClass1(DepSupport1 ds1)
>  {....}
> }
>
> public class ClientClass2 extends ClientClass1
> {
>  private final DepSupport2 ds2;
>
>  @Inject
>  public ClientClass1(DepSupport2 ds2)
>  { super(ds2);
>   ....}
> }
>
> Would it be okey at injection time? I'm afraid of @Inject for
> DepSupport1.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to