spect-oriented programming (AOP), a contemporary programming technology with a large number of supporters, is in essence an improved version of object-oriented (OO) programming technology that enables program objects to be classified and built into hierarchical structures. Its concepts are currently utilized in complex programs that process financial transactions.
Fundamentally, AOP assumes that any complex system has some inherent crosscutting issues and concerns, which traditional programming methodologies do not address well. Aspects are new programming constructs that cross-cut the modularity of traditional programming constructs in carefully-designed and principled ways. For example, a single aspect can affect the implementation of a number of methods in a number of classes, enabling aspects to capture the cross-modular structure of these kinds of concerns in a clean way. This way AOP keeps these concerns from getting tangled by isolating crosscutting aspects into individual blocks.
AspectJ, a general-purpose, aspect-oriented extension to the Java language, is a collection of tools for AOP. Originally developed by professionals from Xerox's Palo Alto Research Center to grow the technology and community in 2002, it has since moved to the Eclipse Project. AspectJ contains expansions and tools that enable Java developers to better manage the problems in large program systems and to reap the benefits of modularity. AspectJ provides clean modularization of crosscutting concerns, such as:
- Error checking and handling
- Context-sensitive behavior
- Performance optimizations
- Monitoring and logging
- Debugging support
- Multi-object protocols
This extension (which you can think of as a plug-in or addition) is not only very easy to learn and use, but since it's developed on the Java platform, it also adheres to the "write once, run anywhere" rule. It can run with any Java program and on any Java-2-compatible platform. Consisting of a compiler, a debugger, a generator of documentation, and a structure browser, AspectJ can offer invaluable assistance with logging, debugging, or testing for almost all projects, making all these procedures as easy as 1-2-3. Developers can also establish further separation from their final software project releases by simply excluding AspectJ from the compilation process.
This article demonstrates how you can use AspectJ in your development processes. It includes a "Hello world" example that already has become very well known in the AspectJ development community. The article can serve as either an introduction or your first endeavor into the AOP world. For a deeper understanding of the topic, consult the official documentation and manuals.