SlideServe
Menu
Préférences
© SlideServe · v2026

A Brief Introduction to Aspect-Oriented Programming

dutch avatar
25 diapositives · 416 Views · Oct 12, 2014

A Brief Introduction to Aspect-Oriented Programming. Historical View Of Languages. Procedural language Functional language Object-Oriented language. Acknowledgements. Zhenxiao Yang Gregor Kiczales. Procedural Language. Also termed imperative language Describe

A Brief Introduction to Aspect-Oriented Programming - slide 1
01 / 25A Brief Introduction to Aspect-Oriented Programming
1 / 17

Télécharger la présentation

A Brief Introduction to Aspect-Oriented Programming
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. A Brief Introduction to Aspect-Oriented Programming

  2. Historical View Of Languages • Procedural language • Functional language • Object-Oriented language

  3. Acknowledgements • Zhenxiao Yang • Gregor Kiczales

  4. Procedural Language • Also termed imperative language • Describe • An explicit sequence of steps to follow to produce a result • Examples: Basic, Pascal, C, Fortran

  5. Functional Language • Describe everything as a function (e.g., data, operations) • (+ 3 4); (add (prod 4 5) 3) • Examples • LISP, Scheme, ML, Haskell

  6. Logical Language • Also termed declarative language • Establish causal relationships between terms • Conclusion :- Conditions • Read as: If Conditions then Conclusion • Examples: Prolog, Parlog

  7. Object-Oriented Programming • Describe • A set of user-defined objects • And communications among them to produce a (user-defined) result • Basic features • Encapsulation • Inheritance • Polymorphism

  8. OOP (cont’d) • Example languages • First OOP language: SIMULA-67 (1970) • Smalltalk, C++, Java • Many other: • Ada, Object Pascal, Objective C, DRAGOON, BETA, Emerald, POOL, Eiffel, Self, Oblog, ESP, POLKA, Loops, Perl, VB • Are OOP languages procedural?

  9. We Need More • Major advantage of OOP • Modular structure • Potential problems with OOP • Issues distributed in different modules result in tangled code. • Example: error logging, failure handling, performance optimizations • Potential result: Tangled Code • Change in the way logging is done affects many classes

  10. Example of Tangled Code Red indicates the error-logging code

  11. Untangling the Tangled Code • Constraint: • Want to preserve the benefits of OOP (encapsulation, modularity, inheritance, etc.) • Potential Solution: • Aspect-Oriented Programming

  12. Basic Concepts in AOP • Crosscutting: straddle across functional and hierarchical boundaries • Aspect: • Property cannot be cleanly encapsulated into a single procedure • Tend to affect performance or semantics of components in systematic ways

  13. AOP: Languages • Components: • Component program • Aspect definition • Aspect Weaver • Constructs: • Join point: execution point in component program for integrating aspects • Pointcuts: refers to collection of join points and values of variables at those points • Advice: method-like constructs that define additional behavior at join points • Aspects: “units of modular cross-cutting implementation” • Pointcuts • Advice • Regular (Java) code

  14. AspectJ by Example

  15. AspectJ by Example (cont’d) • Define pointcuts • Define advice • Introduction

  16. Pointcuts • pointcut • pointcut move(): call(void FigureElement.setXY(int,int)) || call(void Point.setX(int)) || call(void Point.setY(int)) || call(void Line.setP1(Point)) || call(void Line.setP2(Point)); • pointcut producecall(void Figure.make*(..)) • pointcut setXY(FigureElement fe, int x, int y): call(void fe.setXY(x, y));

  17. Advice • Advice • after(): move(){ System.out.println(“A figure element moved. ”); } • after (FigureElement fe, int x, int y):setXY(fe,x,y){ System.out.println(fe + “ moved to ” +x,+ “ , ” + y); }

  18. Aspects aspect FigureLog{ pointcut setXY(FigureElement fe, int x, int y): calls(void fe.setXY(x, y)); after(FigureElement fe, int x, int y): setXY(fe, x, y){ System.out.println(fe + " moved to (" + x + ", " + y + ")."); } }

  19. Introduction • Introduction • Add members to a set of Classes • Change inheritance structure of classes

  20. Introduction (cont’d) aspect PointObserving { private Vector Point.observers = new Vector(); public static void addObserver(Point p, Screen s) { p.observers.add(s); } public static void removeObserver(Point p, Screen s) { p.observers.remove(s); } .... }

  21. Introduction (cont’d) public class A1{ function foo(){…} } public class A2{ function foo(){…;super.foo();…} } public class A3{ function foo(){…;super.foo();…} } aspect A1A2A3{ declare parents: A2 extends A1; declare parents: A3 extends A2; }

  22. Introduction (cont’d) public class A1{ function foo(){…} } public class A2{ function foo(){…;super.foo();…} } public class A3{ function foo(){…;super.foo();…} } aspect A1A3A2{ declare parents: A3 extends A1; declare parents: A2 extends A3; }

  23. What Can AspectJ Do for Us • Developing • Tracing, Logging, and Profiling • Pre- and Post-Conditions • Contract Enforcement • Production • Change Monitoring • Synchronization • Context Passing • Providing Consistent Behavior • Introduction

  24. Conclusion and Open Issues • AOP vs OOP • AOP is not substitute for OOP • AOP makes OOP more powerful • AOP also has runtime overhead • We should use OOP as much as possible • Reuse of aspects • Tool support

  25. Related Work • AspectJ • Reflection and meta-object protocols • Meta-object provides mechanism to control over base-objects • Subject-Oriented Programming • Intentional Programming