Aspect-Oriented Programming

Aspect-Oriented Programming (AOP), a.k.a. Aspect-Oriented Software Development (AOSD), is an attempt to address cross cutting concerns in applications. The dominant decomposition into modules usually reflects the domain model or perhaps the implementation infrastructure. However, it becomes difficult to add in globally-consistent features, like logging, that cut across these module boundaries. AOP attempts to solve this problem.

AOP requires two features to implement aspects, which are analogous to objects in Object-Oriented Programming:

  • Quantification: The ability to specify in a concise way the points in the code, called joinpoints, where behavior needs to be intercepted and possibly modified. Usually this set of joinpoints is called a point cut (yes, there’s a space here, but not in “joinpoints”).
  • Advice: The code to invoke at each joinpoint, which could actually replacing existing code with new behavior.

However, in practice, AOP didn’t become as useful as originally expected. It works well for injecting code modifications, like monitoring, debugging, and logging logic. However, other mechanisms were found to be “good enough” for addressing cross-cutting concerns.

I developed two AOP-based tools, Aquarium, an AOP toolkit for the Ruby language, and Contract4J, a Design by Contract tool for Java.