Presentation is loading. Please wait.

Presentation is loading. Please wait.

Aspect-Oriented Programming: An Overview Brandon Wirick Feb. 2005.

Similar presentations


Presentation on theme: "Aspect-Oriented Programming: An Overview Brandon Wirick Feb. 2005."— Presentation transcript:

1 Aspect-Oriented Programming: An Overview Brandon Wirick Feb. 2005

2 Layers of Abstraction  Machine code to assembly  Assembly to procedural languages  Procedural to object-oriented Group similar compile-time functional units  Object- to aspect-oriented Group similar run-time functional units

3 Terminology  AOP  AOSD  Concerns common crosscutting  Aspect  AspectJ  Join-point  Poincut  Weaving compile-time run-time  Loop fusion  Tangling

4 AspectJ  Java with aspects  Aspects are singleton classes Group join-points into pointcuts Define behavior before, after, or around pointcuts Specify contract enforcements Can contain members, like classes  Definitely most prominent language

5 AspectJ Example public aspect NoNulls { public static interface Addable { public boolean add(Object o); } pointcut add(Object o) : call(boolean Addable.add(Object)) && args(o); boolean around(Object o) : add(o){ boolean success = (o != null); success &= proceed(o); return success; } class NoNullsVector extends Vector implements NoNulls.Addable {} class NoNullsArrayList extends ArrayList implements NoNulls.Addable {}

6 Kiczales et al, 1997  Noted certain problems could have implementations that are either Efficient, but hard to understand Inefficient, but easy to understand Efficient and easy to understand, but only with AOP!  “Reduction in bloat due to tangling”

7 Design Pattern Libraries public abstract aspect ObserverProtocol { protected interface Subject {} protected interface Observer {}... protected abstract pointcut subjectChange(Subject s);... public aspect ColorObserver extends ObserverProtocol{ declare parents: Point implements Subject; declare parents: Screen implements Observer;...

8 Not for Dumb Programmers  Easy to do wrong  Complicated to understand  Controversial Not so much anymore Arguments against AOP pretty weak  Some unpredictable behavior?


Download ppt "Aspect-Oriented Programming: An Overview Brandon Wirick Feb. 2005."

Similar presentations


Ads by Google