News for hackers. Stuff that matters.
Re:Why and how to use service injection in Node.js by tarkin2 on Sunday October 31, 2021 @03:24PM (#29059584)
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).

Re:Why and how to use service injection in Node.js by plmpsu on Sunday October 31, 2021 @05:11PM (#29060488)
It 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.

Re:Why and how to use service injection in Node.js by tarkin2 on Monday November 01, 2021 @06:06AM (#29064776)
No, 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.