| |||||||||
In computing, the programming paradigm of aspect-oriented programming (AOP) centers on constructs called aspects, which treat concerns of a separate set of objects, classes, or functions. Although commonly associated with object-oriented programming (OOP), aspect-oriented programming concepts need not confine themselves to the OOP world .
Any program has principled points (join points) where programmers can identify and modify the program semantics. In AOP, programmers use a language-feature called a pointcut to specify join points, and advice (code like methods or functions) to specify the behavior to join at those points. Some variants of AOP also enable programmers to extend the types in the system. Together, these features enable aspects to implement behavior for concerns that crosscut the core concern of the application.
For example, a telecommunications application might have a core concern of routing calls, but code for timing and billing those calls would crosscut the whole object hierarchy. Aspect-oriented programming has the design goal of separating these concerns from the core concerns. It moves code not related to solving the domain problem from the business logic into a separate module. The application code no longer contains pieces of crosscutting concerns scattered across modules; instead, programmers maintain crosscutting concerns in aspects; this makes it easier to maintain both the core and crosscutting concerns.
The steps to successful aspect-oriented programming comprise:
The sequence of steps results in an easy-to-use solution woven from smaller solutions. IDEs and debuggers can display crosscutting concerns in a natural way.
AspectJ, based on Java, developed at Xerox PARC by Chris Maeda of Xerox PARC, who originally coined the term "aspect-oriented programming": no one remembers exactly when. Gregor Kiczales, it is worth noting, coined the term "crosscutting". The Xerox group's work was later integrated into the Eclipse Foundation's Eclipse Java IDE, which has become one of the most widely-known aspect-oriented language.
Aspects emerged out of object-oriented programming and have functionality similar to using meta-object protocol. Aspects relate closely to programming concepts like subjects, mixins, and delegation.
From a mathematical point of view, one could see aspects as a second-order extension of any programming paradigm: while usual programming paradigms allow reasoning about single functions, messages and so forth by a function/message signature, aspect-oriented programming enables reasoning about entire sets of those entities by using pointcuts with wildcards in their signature. Thus one could view AOP as a powerful, logical extension -- rather than as a fully-flavoured independent paradigm. Friedrich Steimann, for example, has proposed such a view.
But in fact, AOP proponents promote it as an external package shippable along with some application. The program itself has for example no support for security, but voilà! The AOP package can serve as a modular extension to the application serving the needs of the customer.
While at the syntactic level AOP program code appears separate, separation does not apply at run-time level. Without a declaration of dominating aspects, concern-weaving can become unpredictable. In fact, the reality of debugging code poses one of the hardest problems for the AOP community. If the separation of code looms as such a large concern, maybe other ways to achieve this exist, such as C#'s partial types... However, such approaches lack a quantification mechanism enabling programmers to reach several join points of the code with one declarative statement.