The IOC control reversal is embodied in two concepts in terms of: 1, control 2, inversion
Control: What exactly does it take to control? A: The control of the Create object, that is, the implementation of a specific interface to select control of the class .
Reversal: Who was the original control? Who should be given control? A: Generally we use what object directly in the call class new, then the first control is to call the class. Then give control to a third party to decide.
The IOC is not straightforward enough, so the industry has been extensively discussed, and eventually the software world's leading figure Martin Fowler proposed the concept of Di (Dependency injection: Dependency injection) to replace the IOC
DI Dependency Injection: The dependency of the calling class on an interface implementation class is injected by a third party (container or collaboration Class) to remove the invocation class's dependency on an interface implementation class.
(container or collaboration class) such as the Bean container in spring:
<?XML version= "1.0" encoding= "UTF-8"?> <Beansxmlns= "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 "> <BeanID= "Interface Class"class= "Implementation Class"/> <BeanID= "Call class ID"class= "Call class"P: interface class-ref= "Interface Class"/></Beans>
IOC control reversal