4 ms·
DI is a horrible mess of, generally, generated code, at least in the Java/Kotlin world. It promises dependency scopes but I find this rarely needed and if it i
by tarkin2 5y ago
DI is a horrible mess of, generally, generated code, at least in the Java/Kotlin world.
It promises dependency scopes but I find this rarely needed and if it is a lookup table suffices.
It promises to create a graph of dependencies for the dependencies but I'd rather manually specify these rather than let a DI framework strangle my codebase.
It promises to let you mock out dependencies in unit tests but you can do so anyway as long as your dependencies are specified in the constructors.
Honestly, it was new, hip and trendy and even has its own buzzword "inversion of control", and it got to a point where you were thought to be a good developer if you were using DI, regardless of whether you actually should.
It got famous, people got excited, somehow people thought only good developers used it, it's everywhere, people are starting to regret it, and some point it'll only be used when necessary (give it a few more years).
- plmpsu 5y agoIt sounds like you are doing DI without a framework. DI/IoC the pattern seems to be working for you fine if I'm reading your comment right. Manually doing DI becomes interesting/challenging when not all of the injected objects are singletons (i.e., they are tied to a certain context) or when they have a lifecycle.
- tarkin2 5y agoNo, I’m doing it with a framework, Dagger mostly. It works as advertised but the downsides makes it a huge pain. I’d rather do it manually tbf.