- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between IOC and Dependency Injection in Spring.
Inversion of control is a design principle which helps to invert the control of object creation.
According to the paper written by Martin Fowler , inversion of control is the principle where the control flow of a program is inverted: instead of the programmer controlling the flow of a program, the external sources (framework, services, other components) take control of it. It's like we plug something into something else. He mentioned an example about EJB 2.0.
Dependency Injection is a design pattern which implements IOC principle. DI provides objects that an object needs. Let’s say, class X is dependent on Y. So rather than creating object of Y within the class “X”, we can inject the dependencies via a constructor or setter injection.
Sr. No. | Key | IOC | Dependency Injection |
---|---|---|---|
1 | Design Principle | It is design principle where the control flow of the program is inverted | It is one of the subtypes of the IOC principle |
2 | Implementation | It is a term which is implemented by multiple design patterns service locator , events , delegates and dependency Injection | DI is design pattern which can be achieved by constructor and setter injection |
3 | Use Case | Aspect oriented programing is one way to implement IOC | In Case of change in business requirement no code change required |
- Related Articles
- Difference Between Constructor Injection and Setter Injection in Spring
- Difference between Dependency Injection and Factory Pattern.
- Dependency Injection in C#
- Explain dependency injection in C#
- How to implement dependency injection using Interface-based injection in C#?
- Difference between applicationContext.xml and spring-servlet.xml in Spring Framework
- What is dependency injection in PHP?\n
- Difference between DispatcherServlet and ContextLoaderListener in Spring
- How to implement Dependency Injection using Property in C#?
- Difference between @Bean and @Component annotation in Spring.
- Difference between Spring AOP and AspectJ AOP
- Difference between Application context and Beanfactory in Spring framework
- What are the different ways to implement dependency injection and their advantages in C#?
- Difference between JDK dynamic proxy and CGLib proxy in Spring
- \nDifference between Save and SaveAndFlush in Spring Java\n

Advertisements