Creating objects with dependencies - dependency injection

前端 未结 3 1343
醉酒成梦
醉酒成梦 2021-01-06 11:21

Let\'s say we have class:

public class WithDependencies
{
  public WithDependencies(IAmDependencyOne first, IAmDependencyTwo second)
  // ...
}
3条回答
  •  情深已故
    2021-01-06 11:46

    Sometimes I try to get rid of factories or at least not depend directly on them, so Dependency Injection (without factories) is useful of course.

    Therefore I use Google Juice, cause its a small little framework using Java Annotations and you can quickly change your injections / dependencies. Just take a look at it:

    http://code.google.com/p/google-guice/

提交回复
热议问题