How to do manual DI with deep object graphs and many dependencies properly

Posted by Fabian on Stack Overflow See other posts from Stack Overflow or by Fabian
Published on 2010-03-11T14:00:29Z Indexed on 2010/03/12 13:47 UTC
Read the original article Hit count: 291

Filed under:
|

I believe this questions has been asked in some or the other way but i'm not getting it yet.

We do a GWT project and my project leader disallowed to use GIN/Guice as an DI framework (new programmers are not going to understand it, he argued) so I try to do the DI manually.

Now I have a problem with deep object graphs. The object hierarchy from the UI looks like this:

AppPresenter->DashboardPresenter->GadgetPresenter->GadgetConfigPresenter

The GadgetConfigPresenter way down the object hierarchy tree has a few dependencies like CustomerRepository, ProjectRepository, MandatorRepository, etc.

So the GadgetPresenter which creates the GadgetConfigPresenter also has these dependencies and so on, up to the entry point of the app which creates the AppPresenter.

  • Is this the way manual DI is supposed to work?
  • doesn't this mean that I create all dependencies at boot time even I don't need them?
  • would a DI framework like GIN/Guice help me here?

© Stack Overflow or respective owner

Related posts about dependency-injection

Related posts about guice