Note: IOC and AOP are not spring’s ideas. They predate spring, but are more theoretical, and Spring implements them well at the technical level (Java)
I. What is IoC?
Note that this is a technical idea, not a technical implementation.
Things described: Java development domain object creation, management issues
Traditional development methods: for example, class A depends on class B, and usually new an object of B in class A
Development with IoC in mind: instead of going to new objects ourselves, the IoC container (the Spring framework) helps us instantiate objects and manage them. We just ask the IoC container for which objects we need to use
We lose a right (the right to create and manage objects) and gain a benefit (not having to worry about creating and managing objects, etc.)
Why is it called inversion of control?
- Control: Refers to the right to create (instantiate, manage) objects
- Reverse: Control is given to the external environment (Spring framework, IoC container)
Ii. What problems has IoC solved
IoC addresses the coupling problem between objects
Iii. The difference between IoC and DI
DI: Dependancy Injection
How to understand:
IOC and DI describe the same thing, but from different angles