IOC is a design idea called "inversion of Control".
1, the shallow level--from the name of the analysis
"Control" refers to the creation of objects, maintenance, destruction and other life cycle control, this process is generally by our program to actively control, such as using the New keyword to create an object (create), in the use of the process to maintain the reference (maintenance), after the loss of all references by the GC to reclaim objects (destroy).
"Inversion" means that the control of the life cycle of object creation, maintenance and destruction is changed from program control to IOC container, and it is obtained directly from the IOC container by name when an object is needed.
2, a deeper level--reference to Di, dependency injection, is an important implementation of the IOC
The creation of an object often involves the creation of other objects, such as a member variable of object A that holds a reference to another object B, which is dependency, a depends on B. Since the IOC mechanism is responsible for the creation of objects, this dependency must also be handled by the IOC container. The way to be responsible is di--dependency injection, by writing dependencies to the configuration file, and then injecting dependent objects by the IOC container when creating dependent objects, such as when creating a, checking for dependencies, the IOC container injects object B of a dependency into a (assembly, implemented by reflection mechanism) , and then return a to the object requester to complete the work.
3. What is the significance of the IOC?
The IOC does not implement more features, but it does not require much code, does not need to consider the complex coupling between objects to get the right object from the IOC container, and provides reliable management of the object, greatly reducing the complexity of the development.
IOC and DI in Spring