I\'d like to make a picture of what are the possible cases for effective involvement of AOP in application design. All I have met so far is:
INotifyPropertyChanged and similar horrors.
Basically wherever there is code that looks like this - use an aspect and you are done.
I can give you two examples where we use it:
Automatically registering objects in JMX for remote management. If a class is annotated with our @AutoRegister
annotation, we have an aspect that watches for new instantiations of that class and registers them in JMX automatically.
Audit logging (the gold standard AOP use case). Its a bit coarse but the general approach is to annotate methods that represent some auditable action. Combined with something like Spring Security, we can get a pretty good idea of:
We use it for software license management, i.e. allow the software to run only if the computer has some specific license(s) installed. It is not that different from your listed uses, since it is a form of security check.
I published a blog entry describing a practical implementation here
Runtime checking of code contracts. Code Contracts for .NET use AOP for
Runtime Checking. Our binary rewriter modifies a program by injecting the contracts, which are checked as part of program execution.
One effective use of AOP, besides all those you listed, can be validation. Validation of user input, or business objects.
Related articles you must look at.
Wow... 10 years ago - didn't have much for AOP... Here are a few more