David J. Pearce, James Noble. Relationship Aspect Patterns. In Uwe Zdun, Lise B. Hvatum, editors, EuroPLoP 2006, Eleventh European Conference on Pattern Languages of Programs, Irsee, Germany, July 5-9, 2006. pages 531-546, UVK - Universitaetsverlag Konstanz, 2006.
The relationships between objects in object-oriented programs are as important as the objects themselves. Unfortunately, most object-oriented programming languages provide little support for such relationships, leaving the task of implementing them entirely to the programmer. Relationships are typically hard-coded into the participating classes, resulting in tangled code that unnecessarily couples these classes together. The classes become harder to understand and cannot be reused independently. Aspect-oriented programs can model relationships explicitly, treating them as separate concerns that cross-cut their participants. We show how relationships can be implemented as a library of aspects in Aspect/J. Aspects keep relationships independent of their participants, making the resulting programs easier to read, write and reuse, and as efficient as handwritten code.