And making a separate topic for the second half of...
# thinking-together
q
And making a separate topic for the second half of the episode about the list of other ‘things considered harmful’ because it is mostly separate from the previous discussion ^_^’: • Most of your takes are actually luke-warm, in my opinion. 🙂 • Agile (with capital A) considered harmful: 100% agree with your discussion here. • Dependency Injection considered harmful: I disagree. You can definitely use it too much and it would be better if people would approach it from the dependency inversion principle side, but it definitely is better than tightly coupling your code on implementation details. And related to that, I’d like to add: • Inheritance considered harmful: Why do we still teach new programmers how to do inheritance? Besides ‘prefer composition over inheritance’, have we not learned in the last 20-ish years that doing polymorphism based on interfaces/traits creates much more maintainable code?
a
People are doing dependency injection without dependency inversion? Why? How?
q
@Andrew F What I mean is that you should not do dependency injection for its own sake, but as a potential implementation of the dependency inversion principle: If you have an object that ‘does all the things’ which is threaded around everywhere and whenever you need to do anything you use the object, you only make code harder to read. But if you have small objects which each implement only a single well-defined short interface, then it is easy to follow the logic and swap things out. I hope my explanation makes sense
❤️ 1
j
Most of your takes are actually luke-warm, in my opinion.
Yeah, I agree. I was dissatisfied with that aspect of the episode.
but it definitely is better than tightly coupling your code on implementation details
Yeah, I definitely disagree with this one. I'd much rather my application code be about the implementation details. Interfaces don't matter at that level. Implementation details do.
But if you have small objects which each implement only a single well-defined short interface, then it is easy to follow the logic and swap things out.
I just need one interface
call
. 🙂
a
@Andrew F My day job is mostly Angular where pretty much every dependency is injected. I keep finding places where someone wanted an existing object but with minor tweaks, and achieved it by copying the class, making the tweaks, and injecting an instance of the new class by name. I think that’s an example of using DI as if it’s nothing more than a weird way to spell “import”.