| Projection, where the machine of the media uses light and shadow to transmit the message. |
Though not exactly new, AOP is growing in popularity in various diverse software development camps. I believe it is poised for rapid adoption in the next few years. Here, I discuss the drivers and the trends for this technology.
AOP, or Aspect Oriented Programming, is an extension of OOP, or Object Oriented Programming where the repetitious code that is symptomatic of cross cutting concerns is centrally described as a set of advice. Each advice consists of a block of code, a pointcut (i.e. a set of join points or points in the base code) and a description that indicates how to weave the block of code into the matching join points of the base code.
Like most inventions, AOP was invented to solve a problem. In this case, the problem was one of code repetition in large, OOP systems. When you repeat blocks of code in an application, you replicate any bugs or defects in logic that the original block of code contains. If you could specify that block of code only once then specify where to insert that block of code, then you could fix any bugs in that code only once instead of having to fix the block of code everywhere it is repeated.
In OOP, objects of a class inherit state and behavior from other classes. This is one of the most compeling features of OOP that have advanced its adoption. In multiple inheritance, a class inherits from multiple classes. Subtle and hard to diagnose bugs can manifest from non-judicious use of multiple inheritance. One such bug is the dreaded inheritance diamond. That is why most modern software development languages prohibit multiple inheritance. There is one type of multiple inheritance that is very compelling. Called the mixin, it is where a class is the mixture of two base classes of equal abstraction.
There are two types of AOP, a static form and a dynamic form. The static form uses a technique called code weaving. In code weaving a special compiler or preprocessor is used to weave the code. Two popular static AOP implementations are AspectJ and Aspect#.
The dynamic form uses a technique called method interception where each method call is intercepted to determine if the cross cutting code should be executed. This form is best implemented by an IoC framework. Two popular dynamic AOP implementations are Spring and Spring.NET.