I basically want to knwo the major difference between using constructor dependency injection and instantiating the object in the constructor,
For example:
–Creating instance in the constructor
public Class MyService{
private Foo _foo;
MyService(){
_foo = new Foo();
}
}
–Injecting in the constructor
public Class MyService{
private Foo _foo;
MyService(Foo _foo){
this._foo = _foo;
}
}
Now as far as I have read articles/blogs it says in the above code snippet there is tight coupling and in the DI version there is low coupling, now I know the concept of copuling but I am not able to grasp the examples that are provided.. One more difference that I think of is the Lifecycle difference…
But I need someone to clarify it to me. also if I don’t use interfaces while DI, do I really get the benifits of Dependency Injection?