In commonly employed code, there are elements that are orthogonal to the primary functionality of the code. These elements, though extraneous to the primary purpose of the code, are vital to its proper execution. Furthermore, they tend to be scattered throughout the system so that they contribute to the complexity of the code. These elements are called aspects. Examples of aspects include processing to support ‘security’, ‘fault-tolerance’ and ‘synchronization’. Aspect-oriented programming (AOP) isolates aspects into separate modules so that the resulting client-code is more purpose-specific, more reusable, and less complex.
AOP introduced to solve crosscutting problems of OOP. AOP is to OOP what OOP was to procedural languages (i.e. C++ to C). OOP does not allow strong implementation reuse. That is each class must either inherit one base class or use delegation (which breaks instance of tests).Another problem with OOP is certain software properties cannot be isolated in a single functional unit, instead they crosscut multiple components. Such crosscutting concerns result in tangled code that is hard to develop and maintain.
In a general sense, the advance made by AOP has been its potential in complimenting OOP to develop an improved system. Certain aspects, like thread synchronization constraints and failure handling, are systemic in nature and present across components, which implies that they get tangled with the main functionality when developers employ conventional OOP approaches alone. AOP successfully ‘captures’ these aspects, and isolates them as a separate entity. In the end, what results is a system that interweaves both OOP and AOP, and which is clearer and more focused on both the primary functionality and the aspects of its performance.
Object-oriented programming (OOP) has been presented as a technology that can fundamentally aid software engineering, because the underlying object model provides a better fit with real domain problems. However most software systems consist of several concerns that crosscut multiple modules. Object-oriented techniques for implementing such concerns result in systems that are invasive to implement, tough to understand, and difficult to evolve. This forces the implementation of those design decisions to be scattered throughout the code, resulting in “tangled” code that is excessively difficult to develop and maintain. The new aspect-oriented programming (AOP) methodology facilitates modularization of crosscutting concerns. Using AOP, you can create implementations that are easier to design, understand, and maintain. Further, AOP promises higher productivity, improved quality, and better ability to implement newer features.
AOP helps overcome the aforementioned problems caused by code tangling and code scattering. Here are other specific benefits AOP offers:
- Modularized implementation of crosscutting concerns: AOP addresses each concern separately with minimal coupling, resulting in modularized implementations even in the presence of crosscutting concerns. Such an implementation produces a system with less duplicated code. Since each concern's implementation is separate, it also helps reduce code clutter. Further, modularized implementation also results in a system that is easier to understand and maintain.
- Easier-to-evolve systems: Since the aspected modules can be unaware of crosscutting concerns, it's easy to add newer functionality by creating new aspects. Further, when you add new modules to a system, the existing aspects crosscut them, helping create a coherent evolution.
- Late binding of design decisions: Recall the architect's under/overdesign dilemma. With AOP, an architect can delay making design decisions for future requirements, since she can implement those as separate aspects.
- More code reuse: Because AOP implements each aspect as a separate module, each individual module is more loosely coupled. For example, you can use a module interacting with a database in a separate logger aspect with a different logging requirement.
In general, a loosely coupled implementation represents the key to higher code reuse. AOP enables more loosely coupled implementations than OOP.
- a-kernel is an effort to apply AOP techniques to operating system kernel code.
- FACET is a framework for a customizable real-time event channel that uses aspects.
- Lasagne is an aspect-oriented architecture for context-sensitive and run-time weaving of aspects--prototypes have been developed in Java and Correlate.
- QuO is a middleware framework and toolkit which includes aspect-oriented languages for developing quality of service enabled, adaptive distributed object applications.
- SoC+MAS is a research project whose main focus is the application of advanced separation of concerns techniques to handle the complexity of designing and implementing multi-agent OO software.
- SADES is a customizable and extensible object database evolution system implemented using AOP techniques