AOP is used in conjunction with object-oriented programming. By compartmentalizing aspect code, cross-cutting concerns become easy to deal with. Aspects of a system can be changed, inserted or removed at compile time, and become reusable.
placement :
The placement element specifies where code is woven into a method.
before inserts the code inside a method just
before :: it begins any execution (that included execution of initializers)
after :: inserts code at each return statement and at the end of the methodâ~@~Ys block, if it falls through without a return
statement.
around :: executes the code in place of the methodâ~@~Ys original code.
EXAMPLE : aop around class aop {
task disp(){
printf(" aop class ");
ihop($ori_lin);
}
}
extends eaop (aop){
aroundtask disp(){
printf("eaop class ");
}
program main{
aop obj;
obj = new();
obj.disp();
}
RESULTS
eaop class
EXAMPLE : aop before class aop {
task disp(){
printf(" aop class ");
}
}
extends eaop (aop){
beforetask disp(){
printf("eaop class ");
}
program main{
aop obj;
obj = new();
obj.disp();
}
RESULTS
eaop class aop class
EXAMPLE : aop after class aop {
task disp(){
printf(" aop class ");
}
}
extends eaop (aop){
aftertask disp(){
printf("eaop class ");
}