Difference between Spring IOC and Spring AOP

前端 未结 2 808
忘掉有多难
忘掉有多难 2021-02-15 22:36

What is the Difference between Spring IOC and Spring AOP and their Importance ?

相关标签:
2条回答
  • 2021-02-15 23:15

    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.

    0 讨论(0)
  • 2021-02-15 23:29

    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

    0 讨论(0)
提交回复
热议问题