Dependency Injection -Colloquial explanation
Posted
by nettguy
on Stack Overflow
See other posts from Stack Overflow
or by nettguy
Published on 2010-04-08T09:20:43Z
Indexed on
2010/04/08
9:23 UTC
Read the original article
Hit count: 251
Recently I was asked to express the DI in colloquial explanation.
I answered :
1) I am going to a hotel.I ordered food.The hotel management asks me to clean the plates and clean the tables.So here i am a client,I am responsible for managing the service (Instantiating,executing,disposing).But DI decouples such tasks so the service consumer no need not worry about controlling the life cycle of the service.
2) He also asked is there any microsoft API follows DI ?.I answered (This was my guess) In WCF you can create a Proxy using ChannelFactory that controls the life time of your factory.
for item (1) he said only 10% is correct
for item(2) he said that is factory pattern not dependency injection.
Actually what went wrong in my explanation (apart from my bad English) ? What is the real answers for those?
I am waiting for your valuable suggestions.
© Stack Overflow or respective owner