Spring AOP
AOP stands for "Aspect Oriented Programming".
This is one of the most important modules of Spring.
There are some problems with OOP and AOP complements OOP.
Before going further let's understand two things:
a) Primary Logics
b) Secondary Logics
In OOP we develop business method in the class by mixing up both primary logics and secondary logics, because of that there are problems with OOP as follows:
a) Business method becomes clumsy and heavy.
b) Reusability of secondary logic will be killed
c) No flexibility of enabling and disabling the secondary logics without touching the source code.
To overcome above problems, use AOP that makes the programmer to write primary logic in separate class and secondary logic in separate class..
This is one of the most important modules of Spring.
There are some problems with OOP and AOP complements OOP.
Before going further let's understand two things:
a) Primary Logics
b) Secondary Logics
Primary Logics
The logic that is minimum and mandatory to complete a task is called Primary Logic. Without primary logic task can not be completed..
It is also known as business logic..
It is also known as business logic..
eg:- withdraw logic, deposit logic etc..
Secondary Logics
The logic that supports primary logic and makes primary logic as better logic but optional to have in application is called secondary logic.
Without secondary logic we can also complete the task.That is optional in the application..
It is also known as aspects, middleware services,cross cutting concern etc..
It is also known as aspects, middleware services,cross cutting concern etc..
eg:- Security, Loggings, Auditing Transaction management logic etc...
AOP is not replacement of OOP moreover it complements OOP.
Definition of AOP
AOP is a way of programming that makes the programmer to separate primary logics of application from secondary logics..AOP is not replacement of OOP moreover it complements OOP.
OOP Example:
In OOP we develop business method in the class by mixing up both primary logics and secondary logics, because of that there are problems with OOP as follows:
a) Business method becomes clumsy and heavy.
b) Reusability of secondary logic will be killed
c) No flexibility of enabling and disabling the secondary logics without touching the source code.
To overcome above problems, use AOP that makes the programmer to write primary logic in separate class and secondary logic in separate class..
AOP Example:
Advantages of AOP
>> Secondary logics are not mixed with primary logics. There is clean separation.
>> Secondary logics become reusable
>> By giving instruction to AOP enabled software(Spring AOP,AspectJAOP) we can enable or disable secondary logic
NOTE:- We supply primary and secondary logics to AOP enable software and that software takes both the logics and add them together at run time generating a in-memory sub class(Proxy class)...
Post a Comment