One of the best sessions at the AOSD conference was the AspectJ tutorial by Jim Hugunin and Erik Hilsdale. These guys are extremely pragmatic, and that really appeals to me. They’re driven by their goal of getting their technology adopted, and they are interested in anything that furthers that cause. Their pragmatism (and hard work!) is probably the main reason why AspectJ is the clear front-runner in AOP tools.
One of the key ideas that I took away from that tutorial was the notion of enforcing development policies using aspects. One example that particularly resonated with me was the use of an aspect to log all unhandled RuntimeExceptions. This is a great example of a transparent development policy; they program the way they normally do and the policy gets applied by the compiler. The reason why it is a transparent policy has to do with the fact that logging exceptions is orthogonal and (hopefully) free of side effects.
The problem with this example, however, is that it is yet another example of aspects being good for logging. Frankly, there are far too many examples of this sort, and yet it is difficult to envision new applications without appealing to the community at large.
I’m trying to collect information from the community at large as to what kinds of development policies you could see being enforced by aspects. Jim & Erik showed in the AspectJ tutorial an interesting use of a compile-time aspect that would throw a compile-time error if someone tried to bypass a factory pattern when creating objects of a particular type.
I’m very interested in more feedback along these lines. What kinds of development practices require constraints? I’ve already created an aspect that will throw an exception if the size of ViewState in an ASP.NET page exceeds a pre-determined threshold. I suspect that there’s a fair number of these types of constraints that could be weaved into applications using CLAW.