3 ms·
DI is fine, but that's just the concept that you ask for dependencies rather than relying on them. foo(X dep) {} vs foo() {X dep = new X()} It's overused imo
by novembermike 10y ago
DI is fine, but that's just the concept that you ask for dependencies rather than relying on them.
foo(X dep) {}
vs
foo() {X dep = new X()}
It's overused imo but it's fine. The problem comes with DI frameworks like Spring or Angular DI when you start letting the framework tie your code together. This couples you tightly with the framework and can lead to odd situations where the thing you're getting isn't what you're expecting but that's not obvious because the object passing is happening behind a curtain.