4 ms·
I feel like if these classes focused on where objects can shine, like with dependency injection, we'd feel alot different about things. But instead we focus on
by superxpro12 2y ago
I feel like if these classes focused on where objects can shine, like with dependency injection, we'd feel alot different about things. But instead we focus on modelling the problem, without demonstrating how to solve practical issues, and now we're left with this tool that noones knows how to use much beyond a CS203 exam.
- whstl 2y agoIndeed. Dependency injection, interfaces, runtime composition, passing objects/lambdas for configuration/changing behavior (Strategy pattern). Plus teaching proper separation of concerns rather than the "one line per method" from Clean Code. All this would lead to better software than the "Dog inherits from Cat" bs.
- 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.