New answers tagged

1

In my experience, a dependency injection framework leads to a number of issues. Some of the issues will depend on the framework and tooling. There might be practices that mitigate the issues. But these are the issues that I've hit. Non-global objects In some cases, you want to inject a global object: an object which will have only one instance in your ...


0

Yes, when working in Java, I would recommend a DI framework. There are a few reasons for this: Java has several extremely good DI packages that offer automated dependency injection and also usually come packaged with additional capabilities that are harder to write manually than simple DI (eg scoped dependencies that allow automatic connection between ...


1

Does Java + dependency injection = framework required? No. What does a DI framework buy me? Object construction happening in a language that isn't Java. If factory methods are good enough for your needs you can do DI in java completely framework free in 100% authentic pojo java. If your needs go beyond that you have other options. The Gang of Four ...


4

The point of DI frameworks is that they do abstract this part of the design. This has a noticeable impact on the code. Less constructors and less components like Factories or Builders, so part of the code becomes much simpler. DI is oriented to declarative programming. It basically means that DI is going to be defined by files (xml, properties, ...) or by ...


1

Yes. You should probably read Mark Seemann's book titled "Dependency Injection". He outlines some good practices. Based on some of what you've said, you might benefit from. You should aim to have one composition root or one composition root per unit of work (e.g., web request). I like his way of thinking that any object you create is considered a ...


0

Creating classes and assigning them dependencies is part of the modeling process, the fun parts. It's the reason why most of programmers enjoy programming. Deciding, which implementation will be used and how classes are constructed is a thing which will have to be implemented somehow and is part of application configuration. Manually writing factories is a ...



Top 50 recent answers are included