IOC vs dependency injection

xiaoxiao2021-03-06  45

URL

Http://gigix.blogdriver.com/diary/gigix/inc/dependencyinjection.pdf

In my opinion, IOC describes the concept of control transfer, and Dependency Injection describes a specific way of implementing IOC.

IOC: Do not actively create a class, set the properties ETC, and give it to the framework.

Realize which specific class is delayed to the deployment phase decision, truly implement the concept of pluggable.

Dependency Injection

Constutor Injection

Setting the value to inject setter injection

Interface Injection

PicoContainer, spring has implemented Dependency Injection

Always feel that Johnson's framework is high.

Service Locator

I can't see what is too big and what is the difference between Assembler, providing a service interface?

For interface programming, dependency injection - is undoubtedly flexible, but if there is a small module of the system, and the demand will not have too much change in the foreseeable future, or even if there is, the interface is completely different. Do necessary such a design? Flexible adds complexity on the other hand, although there is a good frame support.

转载请注明原文地址:https://www.9cbs.com/read-82651.html

New Post(0)