Normally objects are initialized and bound in code itself. Inversion of control is a approach to bind object at runtime using a binder program.
IoC is design patter to give control to components, while it usage Dependency Injection DI to achieve that. DI is helps us giving framework to bind the object at runtime. Example of IoC are,
- Factory pattern
- Service locator framework
Bean creation in Spring XML
- Static Factory method
- Another factor class and method
- Singleton - Will have only one thorough application.
- Prototype - Can have multiple objects.
- Request - Will store variable on a request and recreate on new request.
- session - Will create and keep been on session.
- global-session - consider it as application scope. Rarely changes.