The example of car and automobile is not a good one.
car is an "instance" of automobile, it inherits from it.
For me it is nonsense to set a DI between them...
Samuel Adeshina - 2015-11-04 17:48:24 - In reply to message 1 from steven
That's the idea of Dependency Injection. The Car class "MAY" not need every property and behaviour built into the automobile class, what's the point of "INHERITING" everything when you can just inject the automobile object into your car class and call the necessary behaviours and properties you need. It's just an analogy and it's a very good one
Samuel Adeshina - 2015-11-04 17:51:58 - In reply to message 2 from Samuel Adeshina
And then think of a situation where the Car class does not only need to inherit from the automobile class, it also needs to inherit from maybe an "engine" class or a "security" class or even all three! MULTIPLE INHERITANCES?
With DI, you can just pass an instance of all three objects into a setter method or even the constructor.