| |||||||||
In computing, aspect-oriented programming (AOP) is a programming paradigm that centers on constructs called aspects, which treat concerns of a separate set of objects, classes, or functions. Although aspect-oriented programming is commonly associated with object-oriented programming, it is not limited as such.
In any program, there are principled points (join points) where the program semantics can be identified and modified. In AOP, the programmer uses 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, in a telecommunications application, routing calls would be a core concern, but code for timing and billing those calls would crosscut the whole object hierarchy. Separating these concerns from the core concerns is the design goal for aspect-oriented programming. 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, a crosscutting concern is maintained in an aspect; this makes it easier to maintain both the core and crosscutting concerns.
The steps to successful aspect-oriented programming are...
The result is an easy-to-use solution woven from smaller solutions.
The most widely-known aspect-oriented language is AspectJ, which is based on Java, and was created at Xerox PARC and integrated into IBM's Eclipse Java IDE.
Aspects emerged out of object-oriented programming and are similar in function to using meta-object protocol. Aspects are closely related to programming concepts like subjects, mixins, and delegation.
The term aspect-oriented programming was coined by Chris Maeda (of Xerox PARC), though the exact date when is not known. The term crosscutting was coined by Gregor Kiczales.
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 entires sets of those entities by using pointcuts with wildcards in their signature. Thus, AOP can hardly be seen as an own fully-flavoured paradigm but rather as a powerful, logical extension.