Hacker News new | ask | show | jobs
by Avi-D-coder 633 days ago
Yes, the dependency inversion principle is not a commonly held principle in FP or imperative paradigms.
2 comments

Wow when I read this comment I did a double take and had to go to Wikipedia… then I realized dependency inversion is not the same thing as inversion of control and things made much more sense.

I guess part of the confusion came from how dependency injection is a form of inversion of control… the words are all very similar to dependency inversion.

I think your identification of that distinction is entirely too generous. Typically the derision of dependency inversion extends to inversion of control since they are cut from the same cloth. One just focuses on what is being inverted and the other the process of inversion.
I haven't internalised what inversion of control means, but I'm very strong on the distinction between dependency inversion and dependency injection frameworks.

With DI, you stop your business logic from knowing about your Postgres database.

With DInjF, not only does business logic still know about Postres, but now it knows about Spring too! (The upside is that it takes fewer lines of code to get from 0 to spaghetti)

So passing functions to functions instead of explicitly calling them is what exactly then?
Higher order functions can be used for dependency injection.

Dependency injection and the Dependency inversion principle are not one and the same.

The principle makes a claim, that inversion is a good onto itself.

Injection is a tool not a claim.

The principle is not making any claim. It is simply a method to achieve something.
Dependency injection