Difference between Spring IOC and Spring AOP

Have you searched the web for IoC and AOP? There are a lot of references to both.

In a nutshell, IoC allows an external force to determine what implementation will be used by code rather than the code determining the implementation. The "external force" might be a configuration file, a unit test, other different code, etc.

AOP allows cross-cutting concerns to be implemented outside of the code affected by those concerns.

The "purpose" of Spring includes IoC and AOP, but goes quite a ways beyond that in its scope.

For more details please check.

Inversion of Control Containers and the Dependency Injection pattern and Aspect-oriented programming Also check this

What is AOP, Dependency Injection and Inversion Of Control in Simple English

IoC, AOP and more


Spring IOC: In simple answer normally you create object with new operator and set yourself for getter and setter. So, yes we use new operator in Java to create object. There is no any bad in doing this. But, when your project size grows and lots of developers are working, and you want to achieve POJO-based programming, you can use DI. So then maybe your question arises - why I can not code it myself? Of course you can use the power of reflection, annotation, and XML. But, some other had already coded this then why not reuse the third party one? There are lots of options for you to choose; Spring can be the best one. It manages your object life cycle from object creation to its destruction. You use the objects created and set by Spring DI container but you do not create them yourself.

Spring AOP: It is related to cross cutting concern. What it mean is in large system the common functionality is scattered throughout different modules. So AOP provides an easiest way to take out a common implementation in the form of 'aspect'. You can also in this case write own implementation using proxy concept but you can reuse the code of proxy based that is implementation of APO alliance using Spring.

Tags:

Spring