springinversion-of-controlaop

What is the relationship of IoC and AOP?


I am reading spring docs this site.

and I already have knowledge IoC(or DI) and AOP a little bit.

While reading docs, I read this phrase.

Foremost amongst these is the Spring Framework’s Inversion of Control (IoC) container. A thorough treatment of the Spring Framework’s IoC container is closely followed by comprehensive coverage of Spring’s Aspect-Oriented Programming (AOP) technologies.

As far as I know, IoC is how Container creates instances and injects them when needed, and AOP is perspective-oriented programming;How you can focus on what you want to do.

However, I understand the above phrase that AOP works well thanks to IoC.

I'm not sure what's the relationship between the two.

Wait for a good answer.


Solution

  • An IoC framework allows injection of an implementation through an external influence, typically configuration.

    AOP's purpose is to enable loose weaving of other concerns into business logic code without direct modification of the code.

    Spring is a framework that extensively uses AOP to enable implementation of IoC.

    There is a whole lot of reading material on both patterns available on the web. For IoC start here. For AOP, I found this helpful.