AspectOriented Programming: - PowerPoint PPT Presentation

About This Presentation
Title:

AspectOriented Programming:

Description:

Define behavior before, after, or around pointcuts. Specify contract enforcements ... 'Reduction in bloat due to tangling' Design Pattern Libraries ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 9
Provided by: usersCsc
Category:

less

Transcript and Presenter's Notes

Title: AspectOriented Programming:


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?
Write a Comment
User Comments (0)
About PowerShow.com