Notes about Aspect Oriented Programming (AOP)

Gene Michael Stover

created 13 March February 2004
updated 13 March February 2004

Copyright © 2004 Gene Michael Stover. All rights reserved. Permission to copy, store, & view this document unmodified & in its entirety is granted.


Contents

1 Introduction

These are my own notes about Aspect Oriented Programming. It would be equally accurate to say ``These are disorganized & not nearly authoritative notes & references about Aspect Oriented Programming''.

By the way, don't assume that the existence of these notes indicates I think Aspect Oriented Programming is great, good, useful, or destined to be the next big thing in software development.1 I just wanted to figure out what it's about, how I might use it, or what ideas I might take from it even if Aspect Oriented Programming as a whole is not very useful.

2 Motivation

I'm most interested in how to implement AOP concepts in languages without using an AOP compiler.

3 What is AOP?

What's written in this section could be wrong. It conveys my understanding of AOP as I study it. As I study, my understanding evolves, & so will my words here.

I still don't know precisely what an aspect is. The best description I have is that it is a way of grouping code which is related but which, in a purely OO programming system, would be separated, scattered around an application. Oft-sited examples of unquestionably good aspects are synchronization policies, authentication, session management & user preferences.

3.1 Some more thoughts

These thoughts are excerpts from an e-mail I sent.

Pavel wrote:

I have a nagging suspicion that AOP is synonym to Policy-Based Programming (PBP), also formalized as Strategy pattern (I hope I quote the right gang-of-4 pattern).

I think you've named the right pattern, & I think your suspicion is a good one. Once you said, it, I could immediately see similarities between what little I know of aspects & Policy Based Programming.

I can also see one thing aspects can do that I'm not sure could be easily donw with the Policy pattern. I still haven't seen a real aspect in detail, but what I have read hints that you can define an aspect & your aspect language (or framework) will automagicaly attach it to ``cut points''. It sounds like cut points can be placed on methods, & most AOP systems assume a method's name identifies a cut point. In other words, you might define an aspect that has a chunk of code that should be executed immediately before every ``readDatabase'' method & another chunk of code to be executed immediately after the ``readDatabase'' methods (maybe the chunks lock & unlock the database). Then, a ``readDatabase'' method on any object, anywhere in the hierarchy (or any of your hierarchies) will automatically execute the aspect's ``before readDatabase'' code & ``after readDatabase'' code. And the aspect can be defined after the ``readDatabase'' methods in your app.

To achieve that functionality with the Policy pattern, I think you'd need to call its methods (or create an instance or however your programming language does it) within each of your readDatabase methods.

Am I missing something? Is there some other way that Policy could be used to get that ``define chunks of code after the fact & outside of methods'' functionality?

Here's a thought about AOP from what I wrote (above) about aspects: If a method's name defines a cut-point, & maybe if programmers can force other cut-points onto methods by name (maybe by attaching cut-point labels to methods - can't do it in C++ or Java directly, but some kind of preprocessor might do it, or some run-time library might offer the feature. You could do it easily in Lisp, neener neener.) Anyway, so let's say cut-points have names & you can apply those names to methods so that your aspect system can figure out what chunks of code from what aspects to apply to the methods. That means that in a large system you'll need to define conventions by which cut-points are named & applied. As we know from the conventions we have for class names & method names, the ``cut-point name'' conventions could themselves become problems.

(The previous paragraph was somewhat speculative of me. I know that AOP has ``cut points'' & that the AOP system uses them to figure out how to match aspects with methods, but I don't know for sure that cut-points have names or even that they can be explicitly applied by programmers to methods. Also, for all I know, you don't apply a cut-point name to a method as a whole; you apply it at a specific location within the method, just like a line of executable code. If so, then the Policy pattern could provide AOP functionality because placing a cut-point name in a method would be just about exactly the same as calling a method on your Policy (or creating a Policy instance or however it's done in your language of choice).)

4 Anotated Reading List

4.1 AOP an Intro

``Aspect-oriented programming: Introduction''.

It turns out that this article is an introduction to the AOP special section of an issue of Communications of the ACM. It's not an introduction to AOP. No need to read it.

4.2 Dynamic Framework

``Separation of coordination in a dynamic aspect oriented framework'' sounds like exactly the type of article I seek.

It's pretty good, though dry & ponderous. I've found one cool concept in it so far. They've given a hand-waving description of what an aspect is, & it has me imagining ways to implement it. Also ways in which it'll bite you in the ass when you try to use it in a big program. (Isn't that how ALL programming techniques work? Looks great in the examples, probably does save you some time in a big app, but it WILL bite you in the ass once in a while.)

Another interesting idea in that article is that AOP languages, which use a compiler (or post-compiler) to inject AOP into the object code, are inferior to dynamic composition of aspects. They point out that if you do static aspects, you loose all the aspect information at run-time. The idea appeals to me probably because I prefer dynamically typed languages.

The rest of the article is not as interesting or useful. It describes the architecture of the authors's online meeting system (or conversation system or crippled MUD, as you will). It describes the functioning of two or three aspects that encapsulate the spaghetti in their application. It does not explain why they are aspects & not objects.

4.3 Pointcuts & Advice in Higher-Order Languages

in progress

Pointcuts & Advice in Higher-Order Languages

At last an article I can recommend highly.

This article discusses ways to apply AOP to functional languages or to implement AOP in functional languages. It uses Scheme for its examples, but it's not specifically about AOP in Scheme. I've only read the first few pages so far, but it has already defined join points & pointcut descriptor, and it is currently describing a nicely simple & generate way in which programs written in a higher-order language can specify pointcut descriptors.

4.4 Composing crosscutting concerns

todo

Composing crosscutting concerns using composition filters

I am unable to download the PDF of this fucker. It locks up my browser (Mozilla). Surprises the hell out of me. My browser should just send it to a file, not interpret it. Whatever. It's fucked.

I guess I'll have to read the HTML version. Thank god there is one.

4.5 242413

to do

Separation and composition of concerns in the object-oriented model

4.6 Introductory paper

todo

``Aspect-oriented programming''. Appears to be an introductory tutorial, though it uses AspectJ for its examples.

I have a local copy.

4.7 A theory of aspects

todo

``A theory of aspects''. The title is interesting, but the abstract says it's about a particular, theoretical, idealized AOP language.

4.8 Parametric introductions

todo

``Parametric introductions'' appears to be a survey of AOP implementations, though possibly only about languages.

4.9 Weave .Net

todo

The ``Language-independent aspect-oriented programming'' describes a system called Weave .Net. Sounds like it's a library for .Net languages. Hopefully contains suggestions for implementing AOP as a library or tools for other languages.

4.10 A short paper

todo

``Aspect-oriented programming with model checking'' might be interesting if only because it is a short paper about AOP.

4.11 Jiazzi

todo

``Aspect-oriented programming with Jiazzi'' is about a tool for Java, but from the abstract, it sounds like the technique might be applicable to other languages. Sounds interesting.

4.12 Initial Assessment

todo

The title of ``An initial assessment of aspect-oriented programming'' sounds very interesting.

4.13 Does it work?

todo

``Does aspect-oriented programming work?''.

4.14 Aspect COOL

todo

``AspectCOOL: an experiment in design and implementation of aspect-oriented language'' is about Aspect COOL, which is an AOP programming language, which is not of much interest to me. I'd rather read about AOP concepts or how to apply them with existing programming languages. Nevertheless, the abstract suggests to me that the paper will discuss techniques, not just a new language, so it might be worth reading.

4.15 AOP Framework in OO Environment

todo

Haven't tracked it down yet. Here's the bibliography information from an article which refers to it.

C.A. Constantinides, A. Bader, T.H. Elrad, M.E. Fayad, and P. Netinant. Designing an Aspect-Oriented Framework in an Object-Oriented environment. ACM Computing Surveys, March 2000.

4.16 AOP in ECOOP'97

todo

G. Kiczales et al. Aspect-oriented programming. In Proceedings of ECOOP'97. LNCS 1241. Springer-Verlag, 1997.

4.17 Overview of AspectJ

todo

G. Kiczales, E. Hilsdale, J. Hugunin, M. Kersten, J. Palm, W.G. Griswold. An overview of AspectJ. In ECOOP01, June 2001.

4.18 Flexible & Efficient Java Framework

todo

R. Pawlack, L. Seinturier, L. Duchien, G. Florin. Jac: A flexible and efficient framework for aop in java. In Reflection'01, September 2001.

4.19 Semantics of aspect-oriented programming

todo

Ralf Lämmel's page on AOP foundations: Semantics of aspect-oriented programming.2

Looks like exactly what I wanted, a discussion of the language-independant ideas in AOP.

A. Hypernotes


A..1 advice

Need a better definition. Actually, from what little I know, this definition is minimal & accurate, but minimal definitions are not always useful

Advice is the code attached to an aspect.


A..2 aspect

An aspect encapsulates a feature which, if implemented in an object oriented, imperative, functional, or otherwise non-AOP language, would be scattered around an application's source code & would not be encapsulated.

An aspect associates pointcut descriptors & advice.


A..3 join point

Need a better definition.

A join point is a location in a program where the advice from one or more aspects might execute.

The types of locations in the code that an AOP system allows as join points depends on the AOP system, but might include:

AOP systems built on OO systems in which a message send & a method call are separated by more than a single pointer indirection might allow join points when certain messages are sent, or when they are sent from certain methods or objects.

AOP systems built on dynamic or high-order languages might allow join points when:


A..4 pointcut descriptor (PCD)

A pointcut descriptor describes the join points at which an aspect's advice should execute.

The expressive flexibility of pointcut descriptors depends on the AOP system. From what I have read, it sounds like most AOP systems allow pointcut descriptors to include method names & notes about whether the advice should execute before, after, or around the method.

Other join points that many AOP systems might allow in pointcut descriptors include:

Dynamic AOP systems might also allow pointcut descriptors to specify join points as:

B. Links

The Aspect-Oriented Software Development web site is http://aosd.net/.

A. Other File Formats

This document is available in multi-file HTML format at http://lisp-p.org/naop/.

This document is available in DVI format at http://lisp-p.org/naop/naop.dvi.

This document is available in PostScript format at http://lisp-p.org/naop/naop.ps.

Bibliography

Aks96
M. Aksit.
Separation and composition of concerns in the object-oriented model.
ACM Comput. Surv., 28(4es):148, 1996.
http://doi.acm.org/10.1145/242224.242413.

ALMZ01
Enis Avdičauševič, Mitja Lenič, Marjan Mernik, and Viljem Zumer.
Aspectcool: an experiment in design and implementation of aspect-oriented language.
SIGPLAN Not., 36(12):84-94, 2001.
http://doi.acm.org/10.1145/583960.583971.

BA01
Lodewijk Bergmans and Mehmet Aksits.
Composing crosscutting concerns using composition filters.
Commun. ACM, 44(10):51-57, 2001.
http://doi.acm.org/10.1145/383845.383857.

EFB01
Tzilla Elrad, Robert E. Filman, and Atef Bader.
Aspect-oriented programming: Introduction.
Commun. ACM, 44(10):29-32, 2001.
http://doi.acm.org/10.1145/383845.383853.

HU03
Stefan Hanenberg and Rainer Unland.
Parametric introductions.
In Proceedings of the 2nd international conference on Aspect-oriented software development, pages 80-89. ACM Press, 2003.
http://doi.acm.org/10.1145/643603.643612.

KH01
Gregor Kiczales and Erik Hilsdale.
Aspect-oriented programming.
In Proceedings of the 8th European software engineering conference held jointly with 9th ACM SIGSOFT international symposium on Foundations of software engineering, page 313. ACM Press, 2001.
http://doi.acm.org/10.1145/503209.503260.

LC03
Donal Lafferty and Vinny Cahill.
Language-independent aspect-oriented programming.
In Proceedings of the 18th ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pages 1-12. ACM Press, 2003.
http://doi.acm.org/10.1145/949305.949307.

MH03
Sean McDirmid and Wilson C. Hsieh.
Aspect-oriented programming with jiazzi.
In Proceedings of the 2nd international conference on Aspect-oriented software development, pages 70-79. ACM Press, 2003.
http://doi.acm.org/10.1145/643603.643611.

MWB+01
Gail C. Murphy, Robert J. Walker, Elisa L. A. Baniassad, Martin P. Robillard, Albert Lai, and Mik A. Kersten Kersten.
Does aspect-oriented programming work?
Commun. ACM, 44(10):75-77, 2001.

PFFT02
M. Pinto, L. Fuentes, M. E. Fayad, and J. M. Troya.
Separation of coordination in a dynamic aspect oriented framework.
In Proceedings of the 1st international conference on Aspect-oriented software development, pages 134-140. ACM Press, 2002.
http://doi.acm.org/10.1145/508386.508403.

TK03
David B. Tucker and Shriram Krishnamurthi.
Pointcuts and advice in higher-order languages.
In Proceedings of the 2nd international conference on Aspect-oriented software development, pages 158-167. ACM Press, 2003.
http://doi.acm.org/10.1145/643603.643620.

UT02
Naoyasu Ubayashi and Tetsuo Tamai.
Aspect-oriented programming with model checking.
In Proceedings of the 1st international conference on Aspect-oriented software development, pages 148-154. ACM Press, 2002.
http://doi.acm.org/10.1145/508386.508405.

WBM99
Robert J. Walker, Elisa L. A. Baniassad, and Gail C. Murphy.
An initial assessment of aspect-oriented programming.
In Proceedings of the 21st international conference on Software engineering, pages 120-130. IEEE Computer Society Press, 1999.

WZL03
David Walker, Steve Zdancewic, and Jay Ligatti.
A theory of aspects.
In Proceedings of the eighth ACM SIGPLAN international conference on Functional programming, pages 127-139. ACM Press, 2003.
http://doi.acm.org/10.1145/944705.944718.

Gene Michael Stover 2008-04-20