News for hackers. Stuff that matters.
Re:Google’s Wire: Automated Dependency Injection in Go by okeuro49 on Sunday February 19, 2023 @09:23AM (#34857774)
> They optimize for the wrong thing; making code easier to write but harder to read and edit.

No, they optimise for making code easier to test.

Re:Google’s Wire: Automated Dependency Injection in Go by procrastitron on Sunday February 19, 2023 @12:26PM (#34859673)
Perhaps this wasn’t clear enough, but I was making an explicit distinction between dependency injection and dependency injection frameworks.

Dependency injection makes code easier to test, and I’m a big fan of dependency injection.

What I’m opposed to is the frameworks that automate (and often hide) the construction of the dependencies.

As someone else said in this thread “explicit is better than implicit”.

Re:Google’s Wire: Automated Dependency Injection in Go by mrkeen on Sunday February 19, 2023 @01:37PM (#34860426)
DI frameworks always make me deal with way more of the system than I want to.

I want to just be able to 'new' any class in the system, and start playing with it under test.

When I try to test a Parser class under a framework DI, it ends up instantiating the most fiddly bits of unrelated crap. I get null pointers in the database config, which had nothing to do with what I wanted.

It can be controlled, by adding even more annotations and mocking frameworks. But I'd rather take out annotations rather than put them in.

Re:Google’s Wire: Automated Dependency Injection in Go by vips7L on Monday February 20, 2023 @09:43AM (#34868513)
But you don’t have to do it that way? You can still manually instantiate your Parser in your test and have DI