IoC control inversion and ioc Inversion
Ioc control inversion involves two concepts: 1, control 2, and reversal.
Control: What do you want to control? A: control of the create object, that is, control of the specific implementation class of an interface.
Reversal: Who is the initial control? Who should the control be handed over? A: Generally, the new object is directly used in the call class, so the initial control is the call class. Then, the control is handed over to a third party for decision.
IoC is not open enough, so it has been widely discussed in the industry. Finally, Martin Fowler, a senior in the software field, proposed the concept of DI (Dependency Injection: Dependency Injection) to replace IoC.
DI dependency injection: This allows the call class to inject the dependency between the implementation class of an interface by a third party (container or collaboration class) to remove the dependency of the call class on an interface implementation class.
(Container or collaboration class) such as bean container in spring:
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: p = "http://www.springframework.org/schema/p" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id = "Interface class" class = "implementation class"/> <bean id = "call class ID" class = "call class" p: interface Class-ref = "Interface Class"/> </beans>