Aspect-Oriented Programming (AOP)
HOMEAOP - LinksDesktop ComputingObjects Windows XP

AOP - An Introduction

Software Engineering is defined as the establishment and use of sound engineering principles in order to obtain software that is reliable and works efficiently on real machines. Currently software is like clay, it is soft for a while, but then it hardens and becomes brittle and can't be changed easily for use in new contexts. But software should be more like gold, malleable for life and able to adapt and change its shape in response to new needs.

Also as the size of software applications expand at an exponential rate, their complexities are also growing. There are a variety of ways for an application's complexity getting increased. One feature of this complexity is the repetition of functionality such as security, memory management, resource sharing, and error and failure handling throughout an application. This complexity is realized when programmers change an often-repeated feature for an updated or new version of an application. It is difficult for programmers to find every instance of such a feature in millions of lines of code. Failing to find and change every occurrence of this feature promotes bugs in the application.

To overcome this issue, software engineering researchers are developing solid methodologies based on a new programming element called "aspect". An aspect is a piece of code that describes a recurring property of a program. Application can, of course, have multiple aspects. Aspects provide crosscutting modularity. That is, programmers can develop aspects to create software modules for issues that cut across various parts of an application. Thus programmers could thus think of, write, view, edit and otherwise address these issues as a unit, implementing changes or upgrades across all applicable code sections, rather than by having to find and modify each applicable piece of code.

Aspects thus have the potential to make programmers' work easier, less time consuming, and less error prone. Also aspects could also lead to less expensive applications, shorter upgrade cycles, and software that are flexible and more customizable.

Work on aspect-oriented is continuing. Xerox has recently released a real world aspect-oriented language and accompanying tools. Commercial companies have started to use aspects in their application development, such as e-commerce.

AOP - The Origin

Reflection and meta-programming initially gave programmers crosscutting capabilities. However these methodologies were somewhat cumbersome and unrefined and also gave programmers only coarse-grained control over crosscutting issues. Meta-logic protocols increased granularity, while AOP is even finer grained, making it more functional for software engineering.

An unwanted result of cross-cutting concerns written in a traditional programming language is tangling. In object-oriented programming, a software module corresponds directly to a block of executable code. A cross-cutting concern can be located in multiple code blocks. This can turn modules into a tangled mess of crosscutting concerns. AOP people point out that much of the software complexity originates from this tangling. They say programmers need aspects to serve as software abstractions that correspond more to issues of concern than to blocks of executable code. With AOP, a section of source code does not map linearly to a section of compiled code but instead maps to all instances in which a particular aspect appears. Changing a line of AOP code thus has widespread effects on compiled code. This automatically makes AOP a potentially powerful programming methodology towards reducing software complexity.

AOP is designed to provide some of OOP's advantages, such as functionality encapsulation, hierarchical classes, and modularity but AOP can overcome an important disadvantage of OOP. Objects do not help much in dealing with systemic, cross-cutting issues that are not confined to a single class, software module, or hierarchical location. AOP plays a very critical role in this regard.

AOP - The Advantages

AOP provides a fine mechanism programmers can use to write code representing cross-cutting concerns once and have it appear wherever needed. Programmers can write references to aspects at join points, the appropriate places in code where the aspects belong. The references then call the required aspects. The AOP compiler reads the reference and weaves the aspects into the application where they belong. The compiler also combines the separate aspect descriptions into an executable form. This occurs in the same way that an OOP compiler makes sure that method calls happen properly.

Aspects thus eliminate many lines of scattered code that programmers would otherwise have to spend considerable time in writing, tracking, maintaining, and changing. This makes changing and upgrading applications more accurate. Suppose a software is coded using other programming methodologies and if there are many cases of code that need to be changed throughout a program, it is always going to be difficult to find and change each case in a large program. AOP lets programmers change an aspect once and have affect wherever it occurs in an application. Thus AOP helps to improve modularity of an application.

AOP also facilitates reusability, as it is modular. That is, programmers can use aspect modules wherever necessary in an application without rewriting code. People are nowadays concentrating on extending the concept of aspect to component framework, as this will promote further reusability.

AOP - The Languages

Aspect-based languages are really just aspect enhancements to current languages such as Java, C and C++. Thus developers can use AOP in various types of applications, especially highly configurable programs in which the methodology's power would generate the greatest programming and financial benefit. These programs frequently have many recurring issues and also require changes that enable reconfiguration, which are both addressed by aspects. It is being realized that AOP can even be useful in configurable programs, such as platform-portable, multiple-functionality, mobile, or distributed applications in which cross-cutting concerns span only small parts of the system.

Xerox PARC has just released its free, open-source, Java-based, real-world, aspect-oriented language, called as AspectJ 1.0. Developers can use AspectJ for such cross-cutting concerns as logging system operations, debugging, and coding recurrent features. AspectJ tools include the ajc compiler and extensions to Inprise's Java-based Jbuilder programming tool; Sun's Java-based Forte tool; and the open-source, multi-platform Emacs tool. There is AspectC, a C-based aspect-oriented language. This becomes important as there are many mission-critical and embedded application codes written in C.

AOP - Future Directions

It is well known that it is difficult to produce good software systems. Research works have to be carried out on aspect-based languages and compilers. Also AOP needs more tool support.

On concluding, programmers are slowly realizing the importance of aspect-oriented programming as cross-cutting happens to be a new modularity principle. AOP is all set to be an important programming methodology with its advantages are manifold. Thus AOP is yet another grand, all-embracing, and above all untested paradigm that pretends it is all easy. It is bound to shine in overcoming some of the difficulties prevalent in designing, developing and maintaining good software systems.

Back to Top