Thanh Le
1 min readApr 15, 2020

--

Yeah, let’s say “depend” is you have to stick to someone or something that you cannot control the relationship. In the example, if you don’t use IoC, you have to stick with either SendingSMS class or SendingEmail class. Since we changed to use an abstraction ICustomerComm interface, this allowed us more flexible. We can create more concrete classes that inherited from ICustomerComm for instance SendingZalo or whatever communication channel.

And when we say “use”, if you like you can use this one, don’t like then use that one…

The only problem with IoC is we implement choosing above in higher-level module. And that is why we need DI to resolve that problem.

Hope this give you brighter picture.

--

--

Thanh Le
Thanh Le

Written by Thanh Le

A Software Technical Architect — Who code for food and write for fun :)

Responses (1)