250 likes | 368 Vues
This presentation by Roberto Lopez-Herrejon, Don Batory, and Christian Lengauer, introduced by Donny Hallman, delves into the intricacies of AspectJ programming through a disciplined approach. The agenda covers fundamental concepts such as join points, pointcuts, and advice, as well as incremental development, algebraic models, and functional models of aspect composition. Key challenges in aspect-oriented programming and proposed solutions are discussed, emphasizing the importance of formalizing aspect capabilities. The critique highlights the necessity for further research and implementation to evaluate performance impacts.
E N D
A Disciplined Approach to Aspect Composition Roberto Lopez-Herrejon Don Batory Christian Lengauer Presented By: Donny Hallman
Agenda • Terms • Introduction to AspectJ • Incremental Development • Algebraic Model • Functional Model • Proposed Solution • Conclusion
Terms* • Base code – non-aspect part of a program • Join points – points in the structure or execution of the program • Pointcut – a logical description of a set of join points • Advice – additional behavior • Aspect – term for an advice adding behavior to a pointcut. Introduction – function that adds a data member or method to a program. * From wikipedia (http://en.wikipedia.org/wiki/Aspect-oriented_programming)
Introduction to AspectJ • Static Crosscuts BASE CODE class Point { int x; void setX(int v) { x = v; } } ASPECT CODE aspect TwoD { int Point.y; void setY(int v) { y = v; } } + NEW COMPILED CODE class Point { int x; void setX(int v) { x = v; } int y; void setY(int v) { y = v; } }
Introduction to AspectJ (cont’d) • Dynamic Crosscuts ASPECT CODE aspect Logging { after() : execution( * Point.set(..)) { System.out.println(“Logged”); } } BASE CODE class Point { int x; void setX(int v) { x = v; } } + NEW COMPILED CODE class Point { int x; void setX(int v) { x = v; System.out.println(“Logged”); } }
Advice Precedence • Advice Precedence (two options) EXPLICITLY DECLARED declare precedence: Aspect3, Aspect2, Aspect1 • COMPILER DETERMINED • If there are two pieces of advice for the same aspect: • If both are after advice, then the advice that appears later, has precendence over the one that appears earlier. • Other cases, the first has precedence
Advice Precedence Circular problem fixed with declaration
Incremental Development Example (cont’d) DESIRED RESULT ACTUAL RESULT
Incremental Development (cont’d) Possible Solution: *Though a solution, this removes ability to reuse the aspect.
Algebraic Model of Aspects ADVICE (AS SHOWN EARLIER) PURE ADVICE (AS USED IN MODEL) CONCEPTIAL VIEW OF ASPECT
Introduction Sum Point1 = TwoD(Point0) = TwoD + Point0 = {setY + y} + {setX + x} = setY + y + setX + x = {setY, y, setX, x} + differs from AspectJ introduction in that it does not allow member overriding. Also, this model allows new classes and interfaces to a program.
Weaving • Identity – where id is a null advice, program P = id(P). • Associativity – right associative • Distributivity – Weaving distributes introduction sum, where X, Y, and Z are arbitrary program fragments:
Advice Sum Advice sum is characterized by “•”. • also models advice precedence (a3•a1 means apply a1 first then a3) • Identity – if id is a null and “a” a pure advice • Commutativity – The order in which advice is applied matters • Associativity – • is associative because function composition is associative.
Modeling Aspects as Pairs • The first entry is the advice part, and the second is the introduction part, such that for the logging example:
Modeling Aspects as Pairs (cont’d) • The Circular Example:
Aspect Composition (cont’d) • Illustration of the problem: • To apply aspect A2, the programmer is required to know how an advice from a previous step (a1) affects the introduction of the current step. The problem gets worse when more aspects are added.
Functional Model • Compose aspects with functional composition and model as such. • The offending advice from before disappears. • Generalizes to any number of compositions • The weavings that make step-wise development difficult are never generated
Functional Model (cont’d) • The functional model causes the aspects to be expressed in terms of bounded quantification. • The Point example before could be bounded in four ways:
Recommendation • Remove precedence rules and apply advice in the order which it is listed in an aspect file • Precendence should be declared for ALL aspect files. The compile could raise errors if not the case.
Conclusions • Problems occur in AspectJ with step-wise development when pointcuts are not bounded to classes, methods, and variables at a specific stage of program development. • Use of Algebra exposes a source of current problems and reveals a solution. • Investigating other AspectJ capabilities.
Critique of Paper • Important to formalize and analyze AspectJ capabilities in with Algebra. • Model seems to expose problems, and solutions seem reasonable. • Much more research and actual implementation need to be done to show the true impact on performance.