Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Philosophical Questions



2) Can pointcuts be modeled separately from advice?



I think about pointcuts with like a special kind of operations that can be invoked by the system itself when certain conditions are met. These conditions (the jointpoints) and their context (caller object, parameters ...) are part of the signature of the pointcut.
I see the advice as executable code that is associated with a pointcut. In regular OOP you have abstract operations, with signature but without code, and concrete methods (implementations of that operations).
So I think that in AOP abstract pointcuts (without advice) are the equivalent of abstract operations and advice are the concrete methods.

I think these issues are different. Especially if you model something that is/will be implemented in AspectJ, you have to consider the possibility that pointcuts are not defined explicitly. What I mean is you can write an aspect like this:

public aspect ExampleAspect {

before() : pointcut goes here {
...

If the pointcut can be defined within 1 line of code, this is not even considered bad coding (or is it?)
Obviously, the pointcut is still there, but unlike with an OOP method signature, you are not forced to declare the pointcut after a 'pointcut' keyword.
Therefore, IMHO, it would be an overkill to model something that doesn't even appear in the code. I am thinking about a hierarchical AOP model where all the pointcuts (explicit or implicit) would fit in a lower level of abstraction, while at the highest level, implicit pointcuts would (in the best case) be represented by (for instance) UML-like relations... (or something like that).
I also think advice is more than just the implementation of an aspect. At the design level (whatever that is), we don't need the implementation, we just need to know 'what a piece of advice does'. Again, in a hierarchical aspect model, it should be possible to model more detail as we drop a level of abstraction.


Of course advice without a pointcut have no sense in the same way that a piece of code have no sense without an operation with his signature. But it is usefull to have this separation because you could have different advices for the same pointcut (like polymorphic methods in OOP).
To sum up, separation pointcut/advice? yes. Full independence? no, the advice must always run in the context of a pointcut.

I hope getting some feedback about this too.
Cheers,

Alon


Back to the top