3 ms·
It seems to me that you think designing for DI is much more complicated than it actually is. In most modern languages it is trivial to implement. Especially if
by ane 11y ago
It seems to me that you think designing for DI is much more complicated than it actually is. In most modern languages it is trivial to implement. Especially if you have ad-hoc polymorphism available, it comes at virtually no price. Some languages make it more difficult than others, but in most modern languages it's really easy.
Your example of getters and setters is a bit of a red herring. I understand what you mean by it, but it doesn't apply in this case. This is because the getter and setter is an abstraction that derives from encapsulation. But it is also an antipattern. In many cases, getters and setters are just a type of needless complexity--a distraction, overengineering! On the other hand, DI solves a real, practial problem, and if your language is intelligent, it is really simple to implement.