2 ms·
>I feel like if these classes focused on where objects can shine, like with dependency injection Dependency injection is not OOP. When used in an OOP context,
by DeathArrow 2y ago
>I feel like if these classes focused on where objects can shine, like with dependency injection
Dependency injection is not OOP. When used in an OOP context, it just solves an issue created by OOP. In an OOP context you can't call code from another object unless you have a reference to it. So you either instantiate the object or use DI to supply an object reference so you can call a method.
In contrast to that, if you have functions as first class citizens or your code resides in a static class, you seldom need DI because you can call the function or method from wherever you need.
- zelphirkalt 2y agoOr you can easily pass in a closure, that does what is needed. No objects or classes needed for that. You still have DI readily available.