Home >> Computers >> Programming >> Methodologies >> Aspect-Oriented


  Adaptive Programming
  Java Extensions
   

  Development Tools
       


Inside software engineering, the programming paradigm of aspect-oriented programming (AOP), also known as aspect-oriented programs development (AOSD), tries to help software engineer in the separation of concerns, or the breakage down of a program into distinct area that overlap around functionality when little when imaginable. Particularly, AOP focuses on the modularization and encapsulation of cross-cutting concerns.

Gregor Kiczales and his team at Xerox PARC originated this concept. This team besides developed a forevirtually all, & however most popular, AOP language: AspectJ.

Older programming methodologies - including procedural programming and object-oriented programming - similarly focus on separation & encapsulation of concerns (or even any front yard of interest of focus) into lone a cappella. For instance, procedures, packages, classes, & methods completely aid software engineer encapsulate concerns into individual take a breath. However although these methodologies potty with success encapsulate numerous computer software concerns, a few concerns defy such convenient encapsulation. Computer programmer call for these crosscutting concerns, because it survive around several area of the program.

Logging offers the prototypal lesson of the crosscutting concern, because the logging strategy necessarily infects each only logged a share of the patterns. Logging thereby crosscuts everthing logged classes, methods, & procedures.

Generally, an implementation of an AOP language tries to encapsulate these types of crosscutting concerns through the introduction of the up to date construct known as an aspect. An aspect may vary a behavior of the base code (the non-aspect the portion of a program) by using advice (additional behavior) above the quantification of join points (points in the structure or execution of the program), known as the pointcut (the logical description of a placed of join points).

Around numbers of AOP languages, method executions & field information tons exemplify join points. The pointcut might consist, e.g., of completely information to the particular placed of fields.

Motivation and basic concepts
Aspect-Oriented Programming has at its core a enabling of a better separation of concerns, by letting the coder to produce cross-cutting concerns when foremost-class program modules. (Cross-cutting concerns defined when victims area, or even aspects, of the program that within standard project mechanisms prevent higher scattered through multiple program modules, & convoluted sustaining more modules.)

E.g., assume the banking application by having the conceptually super elementary method for transferring an total from either a single account to an additional:

void transport(Account fromAccount, Account toAccount, int total) fromAccount.withdraw(amount); toAccount.deposit(amount); }

(the examples pop up inside a Java-like syntax, since at a instance of writing, an overwhelming majority of AOP-related the food & drug administration and act will require place inside Java or even around Java-variants.)

Nevertheless, around the real-globe banking application, this transport method seems far from either adequate. You must include security checks to verify that a todays user has a authorization to perform this operation. I must enclose the operation within a database transaction in order to prevent accidental information loss. I personally must log a operation to the models log. So in. The super simplified version by using completely victims recently concerns would look somewhat such as this:

void transport(Account fromAccount, Account toAccount, int total) Dealing texas = database.newTransaction(); in case (fromAccount.getBalance() < amount) fromAccount.withdraw(amount); toAcount.deposit(amount); systemLog.logOperation(OP_TRANSFER, fromAccount, toAccount, amount); tx.commit(); }

The code has lost its elegance and simplicity because the various new concerns have become tangled with the basic functionality (sometimes called the business logic concern). The transactions, security, logging, etc. all exemplify cross-cutting concerns.

Also consider what happens if we suddenly need to change (for example) the security considerations for the application. In the program's current version, security-related operations appear scattered across numerous methods, and such a change would require a major effort.

Therefore, we find that unlike the core concerns of the system, the cross-cutting concerns do not get properly encapsulated in their own modules. This increases the system complexity and makes maintenance considerably more difficult.

AOP attempts to solve this problem by allowing the programmer to develop cross-cutting concerns as full stand-alone modules called aspects. In most AOP languages, an aspect comprises one or more pieces of advice (code snippets - like methods) and a list of join points (points in the main program into which the advice should be woven). For example, a security module can include an advice that performs a security check, with instructions to weave this code snippet into the beginning of methods a(), b() and c() of some class. Powerful mechanisms deploy to enable a broad specification of join points, so that developers need not enumerate weaving-destinations manually. These mechanisms are commonly known as pointcut specification languages.

Join points and pointcuts

To make an aspect useful, the developer must specify exactly where in the program each of its pieces of advice must be woven. Possible weaving-destinations, known as join points, are well-defined points along the execution of a program. Join points can include:

Method execution The instantiation of an object The throwing of an exception

Such an expressive language allows developers to provide a broad specification that can automatically enhance (by code weaving) existing as well as future classes.

Features such as the set of supported join points, and the expressiveness of the pointcut specification language, help to differentiate various AOP languages from one another. Whereas some languages (like AspectJ) use a Java-like syntax for specifying pointcuts, others (such as AspectWerkz) use an XML-based syntax; and still other alternatives exist.

Weaving

Weaving - injecting the advice presented in aspects into the specified join-points associated with each advice - provides the final challenge of any AOP solution.

In the original introduction of AOP, Kiczales and his team listed the following possibilities for weaving:

a source preprocessor (similar to that in the original implementations of C++ ) a post-processor that patches binary files an AOP-aware compiler that generates woven binary files load-time weaving (for example, in the case of Java, weaving the relevant advice as each class gets loaded into the Java virtual machine (JVM)) run-time weaving (trap each join point at runtime, and execute all relevant advice)

The first two options complicate the development process, whereas the last two options may slow down the program's execution. The last option (run-time weaving) also requires a special aspect-aware execution environment. In the world of Java, this implies a special JVM.

AspectJ's currently uses a dedicated compiler solution. The compiler generates standard Java binary class files, which any standard JVM can execute.

All of the listed weaving solutions (except the last) imply changing the code at some point; the code generated for a given Java class by the compiler (after processing and/or loading) does not equate to what a standard Java compiler would have generated, since it now contains woven pieces of advice code. Many view this as a major drawback of AOP, because it complicates both the programmer's understanding of the program execution model and the use of any standard, existing tools, such as debuggers (see also "Problems", below).

Cohen and Gil have produced a novel alternative: they present the notion of [http://www.forum2.org/tal/AspectJ2EE.pdf deploy-time weaving]. This basically implies post-processing, but rather than patching the generated code, they suggest subclassing existing classes so that the modifications are introduced by method-overriding. The existing classes remain untouched, even at runtime, and all existing tools (debuggers, profilers, etc.) can be used during development. A similar approach has already proved itself in the implementation of many J2EE application servers, such as IBM's WebSphere.

AspectJ: an AOP language

AspectJ is the most popular AOP language. It is an extension to Java developed at Xerox PARC by Chris Maeda, who originally coined the term "aspect-oriented programming" (no one remembers exactly when). Gregor Kiczales coined the term "crosscutting". The Xerox group's work was integrated into the Eclipse Foundation's Eclipse Java IDE in December 2002. This helped AspectJ become one of the most widely-used aspect-oriented languages.

All valid Java programs are also valid AspectJ programs, but AspectJ also allows programmers to define aspects. Aspects can contain several entities unavailable to standard classes. These are:

inter-type declarations — allow a programmer to add methods, fields, or interfaces to existing classes.

pointcuts — allow a programmer to specify a set of joinpoints (points in the execution of a program). All pointcuts are boolean expressions (quantifications) that evaluate to admittedly anytime the matching joinpoint occurs. For an lesson of the pointcut:

advice — allow the software engineer to specify what actions to perform whilst a pointcut evaluates to avowedly. A actions may be performed prior to, fallowing, or even as much as a specified join point.

AspectJ comes tightly integrated by owning the right placed of information, known as AJDT, which assist developers in the understanding of how else aspects & base code interact.

Around March 2005, a AspectWerkz merged with AspectJ to form one language. More commercial Aspect-oriented frameworks include JBoss and Spring AOP.

AOP and other programming paradigms

Aspects emerged away from object-oriented programming and have functionality similar to meta-object protocols. Aspects relate closely to programming construct prefer subjects, mixins, and delegation. More shipway of utilizing aspect-oriented programming paradigms include Composition Filters and the hyperslices approach.

Mathematically, aspects form a second-order extension of any programming paradigm: while common programming paradigms allow abstract thought just all about lone functions, messages then forth by the function/message signature, AOP enables logical thinking about entire sets of people respire by utilizing pointcuts sustaining wildcards in their signature. So of these can review AOP as a mighty, logical extension, like than as an independent paradigm. Friedrich Steimann, for instance, has proposed such the learn from.

However AOP advocate promote it as an external pack shippable along by using a few application. For instance, in case the program itself has there is no trend lines for security, an AOP pack may help as a modular extension to the application, providing security.

Problems for AOP

Debugging can turn into one of a greatest problems for AOP. When at a syntactical level AOP program code appears separate, at redo-period these are does'nt. Concern-weaving potty turn into unpredictable if it is non specified which aspect should dominate. Designers use considered guide ways to achieve separation of code, like C#'s partial types. But, such approaches lack the quantification mechanism enabling coder to email many join points of the code using of these declarative statement.

An additional condition for AOP is the undesigned capture of joinpoints across wildcards. E.g., believe you specify the pointcut sustaining associated advice as a wildcard in tons methods that have a certain pattern to their spelling. a software engineer world health organization creates the recently method can unknowingly purchase the title to which the advice might - incorrectly - use. Likewise, renaming the method may wholly vary its semantics. Must everthing software engineer world health organization modify the codebase above its life-time view a complex placed of plan-specific naming conventions sequentially to refrain from such difficulties? An AOP-caring development environment might produce a pertinency of advice extra seeable, however these are an open wonder how else such concerns may play retired across a lifecycle of aspect-oriented code.

Implementations
For C#/VB.NET: [http://sourceforge.net/projects/aspectdng/ AspectDNG] [http://aspectsharp.sourceforge.net/ Aspect#] [http://theagiledeveloper.com/articles/Encase.aspx Encase] [http://composestar.sourceforge.net/ Compose*]

For Java: [http://eclipse.org/aspectj/ AspectJ] [http://aspectwerkz.codehaus.org/ AspectWerkz (Now merged with AspectJ)] [http://jakarta.apache.org/bcel/ Byte Code Engineering Library] [http://dynaop.dev.java.net/ Dynaop] [http://jac.objectweb.org JAC] Jakarta Hivemind [http://www.csg.is.titech.ac.jp/~chiba/javassist/ Javassist Home Page] [http://ssel.vub.ac.be/jasco/ JAsCo] [http://www.ics.uci.edu/~trungcn/jaml/ JAML] [http://www.jboss.org/developers/projects/jboss/aop JBoss AOP] [http://www.objectteams.org/ Object Teams] [http://prose.ethz.ch/ PROSE] [http://www.aspectbench.org/ The AspectBench Compiler for AspectJ (abc)] [http://www.springframework.org/ The Spring Framework] when a share of its functionality [http://javalab.cs.uni-bonn.de/research/jmangler/index.html The JMangler Project] [http://injectj.sourceforge.net/ InjectJ]

For Javascript: [http://www.jroller.com/page/deep/20030701 AOP Fun with JavaScript]

For C/C++: [http://www.aspectc.org/ AspectC++] [http://www.pnp-software.com/XWeaver/index.html XWeaver project]

For Python: [http://www.cs.tut.fi/~ask/aspects/aspects.html Lightweight Python AOP] [http://www.logilab.org/projects/aspects Logilab's aspect module] [http://zope.org/Members/pje/Wikis/TransWarp/AOPTutorial/HomePage Python/Transwarp AOP Tutorial] (Replaced by PEAK) [http://peak.telecommunity.com/ PEAK] [http://pythius.sourceforge.net/ Pythius]

For Ruby: [http://aspectr.sourceforge.net/ AspectR]

For PHP: [http://phpaspect.org PHPaspect] [http://www.aophp.net/ Aspect-Oriented PHP]

For Perl: [http://search.cpan.org/perldoc?Aspect The Aspect Module]

For Common Lisp: [http://common-lisp.net/project/aspectl/ AspectL]

For Cocoa: [http://www.ood.neu.edu/aspectcocoa/ AspectCocoa]

For XML: [http://www.aspectXML.org AspectXML]

For Squeak [http://www.prakinf.tu-ilmenau.de/~hirsch/Projects/Squeak/AspectS/ AspectS]

For Flash Actionscript 2.0 [http://www.as2lib.org/ as2lib]

For Other Information (real-globe implementations): [http://www.aosd.net AOSD.net ]

Aspect-Oriented Decomposition and Composition
Free chapter from the book "Generative Programming" - covers basic concepts of AOP with examples in C++, Java, Smalltalk, and in AspectJ, Demeter, SOP and Composition Filters; and techniques for implementing weaving.

Aspect-Oriented Software Engineering at Lancaster University
Rashid et al. work on aspect-oriented programming, specification, and databases.

Multi-Dimensional Separation of Concerns: Software Engineering using Hyperspaces
Hyperspaces allow software enginners to split code - and other software artifacts such as requirements and design documents - along multiple concern dimensions, and recombine them automatically.

MIT Technology Review cites Aspect-Oriented Programming as one of Top Ten Innovations
The respected publication MIT Technology Review predicts that the power of aspect-orientation to separate previously difficult-to-disentangle concerns will make it a big success.

Revisiting Separation of Concerns with an Aspect-Oriented Framework [ECOOP 00 Poster]
Short poster from ECOOP 2000, highlighting the role of AOP in taming component interactions (high coupling).

Workshop on Aspect-Oriented Programming and Separation of Concerns
Proceedings of the workshop are available for free download. [Lancaster University, UK]

Aspect-Oriented Software Development
Aspect-oriented tools and research projects for various languages; applications of AOP; theory; events calendar; discussion and announcement mailing lists.

AOP: Aspect-Oriented Programming
Methodology enabling modularizing of crosscutting concerns. Experience shows that with standard procedural or object-oriented languages it can be hard to modularize many design concerns. Outgrowth of Xerox PARC OO programming research.

Aspectual Components
Paper on the integration of work on aspect-oriented programming, software architecture and component-based software development.

I want my AOP!
A series of 3 articles in JavaWorld magazine, with code examples, on how Aspect-Oriented Programming helps separate concerns and improves maintainability and flexibility.


Computers: Programming: Languages: Object-Oriented
Computers: Programming: Languages: Reflective
Computers: Programming: Metaprogramming
Computers: Programming: Methodologies: Object-Oriented
Computers: Software: Object-Oriented




© 2005 GeneralAnswers.org