4 ms·
From what I understand, DI simply turns this: public class MyClass { private Dep myDep; void MyClass(){ this.myDep = GetDep();
by Sohcahtoa82 4y ago
From what I understand, DI simply turns this:
public class MyClass {
private Dep myDep;
void MyClass(){
this.myDep = GetDep();
}
}
into this:
public class MyClass {
private Dep myDep;
void MyClass(Dep dep){
this.myDep = dep;
}
}
Why this needs an entire framework is beyond me. It feels like all they do is convert explicit code into boilerplate which then becomes much harder to reason about.
- confidantlake 4y agoI think the theory is when you want to change the dep you can do it in a config file instead of in the code. But I totally agree, I don't think the value is worth the cost.