What Is IoC?
IoC transfers the control of objects or portions of a program to a container or framework . often use it object-oriented programming
.
The advantages of this architecture are:
1、
decoupling【解耦】
the execution of a task from its implementation
2、easier toswitch
between different implementations
3、greatermodularity【模块性】
of a program
4、easy test a program by isolating a component ormocking
its dependencies
Achieve IoC through various mechanisms
1、Strategy design pattern,
2、Service Locator pattern,
3、Factory pattern,
4、Dependency Injection (DI)
参考:
Intro to Inversion of Control and Dependency Injection with Spring