Aspect-Oriented Programming Using AspectJ(TM)
Cristina Videira Lopes and Gregor Kiczales
Xerox Palo Alto Research Center
3333 Coyote Hill Rd.
Palo Alto, CA 94304
Tel: +1 (650) 812-4498
Fax: +1 (650) 812-4334
Traditionally, programs involving shared resources, multi-object protocols, error handling, complex performance optimizations and other systemic, or cross-cutting concerns have tended to have poor modularity. The implementation of these concerns typically ends up being tangled throughout the code, resulting in systems that are difficult to develop, understand and maintain.
Aspect-oriented programming is a new technique that has been proposed specifically to address this problem. Aspects are new programming constructs that work by cross-cutting the modularity of traditional programming constructs in carefully-designed and principled ways. So, for example, a single aspect can affect the implementation of a number of methods in a number of classes. This enables aspects to capture the cross -modular structure of these kinds of concerns in a clean way.
AspectJ(tm) is a general-purpose aspect-oriented extension to Java. Using AspectJ, we can:
This tutorial shows how to design and program with aspects and how aspects can be used to improve separation of concerns in complex software systems. Particular attention will be given to how AspectJ can support the implementation of common OO patterns. The audience should have experience with an object-oriented language, preferably Java.
Relevance to ETAPS
We believe this tutorial is well within the scope of ETAPS, and, in particular, of its conferences ISOP and FASE.
AOP extends existing design and implementation techniques with
AOP has been presented primarily to the object-oriented programming community (ECOOP, OOPSLA), with an ever increasing interest from that community. There have been 3 workshops about AOP (2 at ECOOP and 1 at ICSE), also with an ever increasing number of participants.
Although AspectJ is an extension to object-oriented programming (Java in particular), AOP applies not only to OO but to software systems in general.
[Note that despite the fact that this tutorial presents a system with a "TM", it isn't a commercial tutorial.]
A half-day version of this tutorial was presented at ECOOP'98 and will be presented at OOPSLA'98. The full day version extends that tutorial with more material for applying aspects in practice.
Purpose and scope
The tutorial is devoted to presenting a new perspective - AOP - on designing and implementing software systems. Attendees will get a sound understanding of the concepts of AOP. The tutorial shows how to design and program with aspects and how aspects can be used to improve separation of concerns in complex software systems. Particular attention will be given to how AspectJ can support the implementation of common design patterns.
The tutorial focuses on concrete examples that illustrate how AOP and AspectJ can be useful in practice. Those examples show aspects for:
Key learning objectives and intended audience
Attendees will learn
At the end of the tutorial, the curious minds should also have an idea of some of the open issues and challenges related to this techonology.
Attendees should have some experience with an object-oriented language, preferably Java.
We expect a mix of people from different backgrounds: practicioners who build software systems, researchers in PLs and SE, and students looking for new topics.
Cristina Videira Lopes is a research scientist at the Xerox Palo Alto Research Center. Her interests are in software engineering and programming languages. She has been developing aspect-oriented programming languages, in particular for distributed applications.
She has been co-organizer of a series of workshops on AOP at ECOOP and ICSE. She serves on the program committee for ECOOP'99.
Gregor Kiczales is a principal scientist at the Xerox Palo Alto Research Center. His research interests are in software architecture, programming languages and software engineering. He has worked on a variety of ideas
to better capture the structure of complex software systems, including metaobject protocols, open implementation, and most recently aspect-oriented programming. He is a co-author of "The Art of the
Metaobject Protocol". He has served in several program committees for OOPSLA, ECOOP and other conferences, and has been invited for several keynote addresses.
Outline of tutorial
A 4-hour version of this tutorial can be found at http://www.parc.xerox.com/aop/aspectj/tutorial
We are currently extending the tutorial for a full day. The new material will consist mostly of more concrete examples of aspects in complex systems. The examples are being carefully designed so that they can serve as prototypes of common design situations. We expect to develop a set of guidelines for using aspects in practice.
The following is the table of contents of the current 4-hour version. The full-day version will have more material of the kind that is presented in parts IV and V.
Part I - Introduction [20 min]
Part II - Basic concepts of AspectJ [60 min]
- 1 aspect x 1 class
- 1 aspect x N classes
- M aspects x N classes
- M aspect instances x N objects (state cross-cutting)
Part III - Using AspectJ, the tool [15 min]
Part IV - Using Aspects [90 min]
This part of the tutorial presents 9 examples of aspect programming. These examples are simplified versions of situations with which most software engineers can identify. They are grouped according to four kinds of approaches to using aspects:
catching exceptions more globally
tic-tac-toe notification protocol
the observer pattern
logging new instances
monitoring: aspect instances
extending a server: inheritance of aspects
a specialized aspect library (coolib)
programming a coordination constraint with an aspects
Part V - Style issues [35 min]
Part VI - References, related work, wrap-up [ 20 min]