News for hackers. Stuff that matters.
Re:What's Wrong with Tech Hiring by Akronymus on Thursday September 16, 2021 @09:43AM (#28551671)
Indeed, it is simply passing some dependency as a parameter.

Personally I find DI to make it harder to reason about in a sizeable portion of cases (20ish%) without actually providing a benefit.

So that makes me prefer going for rejection (Passing the result of the dependency instead of the dependency itself) or just keeping it there.

Altough, those approaches depend heavily on the rest of the codebase. (FP makes rejection relatively easy for example)

Re:What's Wrong with Tech Hiring by Aeolun on Thursday September 16, 2021 @10:34AM (#28552349)
DI makes testing nice. People approximate it with hacks, but you need DI for truly good unit tests.
Re:What's Wrong with Tech Hiring by Akronymus on Thursday September 16, 2021 @10:40AM (#28552420)
Really depends on the whole structure. If it is mainly FP, dependency rejection usually is actually the easiest to test with
Re:What's Wrong with Tech Hiring by Aeolun on Thursday September 16, 2021 @11:21AM (#28552961)
I dunno how you can combine dependency injection (as I imagined it in the original comment) with FP in the first place.

Without classes what would you be injecting? Other functions? That’s still something that happens all the time in FP.

Re:What's Wrong with Tech Hiring by Akronymus on Thursday September 16, 2021 @11:27AM (#28553025)
I was thinking sideeffectful functions. Such as DB accesses.
Re:What's Wrong with Tech Hiring by layer8 on Thursday September 16, 2021 @03:11PM (#28555931)
> dependency rejection

That’s secretly the most powerful design strategy.

Re:What's Wrong with Tech Hiring by Akronymus on Thursday September 16, 2021 @04:27PM (#28557088)
It objectively isn't, as there are certain things you can't do with it.

Altough, for usability it is IMO definitely the best.