Aspect Weaving with Graph Rewriting - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Aspect Weaving with Graph Rewriting

Description:

Aspect Oriented Programming (AOP) Graph Rewrite Systems (GRS) Categories ... Aspect Composer Graph Rewrite Rule. Weave ... aspect composers, a component ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 32
Provided by: Lud46
Category:

less

Transcript and Presenter's Notes

Title: Aspect Weaving with Graph Rewriting


1
Aspect Weaving with Graph Rewriting
  • Uwe Aßmann
  • Andreas Ludwig
  • Universität Karlsruhe
  • Institut für Programmstrukturen

2
Overview
  • Aspect Oriented Programming (AOP)
  • Graph Rewrite Systems (GRS)
  • Categories of GRS-based Weaving
  • Generation of Aspect Weavers
  • Conclusion

3
Aspect-Oriented Programming
  • Motivation Separation of Concerns
  • a new kind of modularization
  • separation of cross-cutting code parts
  • Technique Integration by (Static) Weaving
  • Examples for Aspects
  • Synchronization
  • Communication
  • Instrumentalization
  • Memory Management

4
Aspect separation composition
water
Separate plans for each aspect of a building
data
electr.
gas
Exchange of aspects independently of each other
5
Debugging aspect
Algorithm
Persistence aspect
Weaver-Tool
Debugging aspect
Persistence aspect
Debugging aspect
Persistence aspect
Debugging aspect
6
A simple debugging aspect
Method m () print(enter m) abc..
cde.. print(exit m) return
Method.begin
Method.end
7
What a Weaver does...
  • E.g. wrapping debugging aspect

Method m () abc.. cde.. return
Method m () print(enter m) abc..
cde.. print(exit m) return
Method.begin
Method.begin
Method.end
Method.end
... But also much more complex things
8
Successes of AOP
  • AML A Matrix multiplication Language
  • As fast as hand-coded Fortran, faster than C
  • D with three different languages
  • algorithm, distribution, synchronization
  • AspectJ (Kiczales/Lopes Xerox Parc), Hyperspaces
    (Osser IBM)
  • Adaptive Programming (Lieberherr)
  • html (html, css, xsl)
  • SETL and SETL Representation Language
  • Architectural Description Languages

9
Architecture is an Aspect
Connectors
Ports


10
Abstract Communication Ports
m () / ports / e m(d)
m () poout.out(d) poin.in(e)
OUT port
IN port
m () / ports / setChanged(d)
notifyObservers(d) listen_to(e)
11
Problem
  • AOP aims at different problem domains...
  • ... weaving requires different specification
    languages.
  • A new weaver for every weave scenario!
  • Weavers are compilers...
  • Weaving can become complicated...

12
Idea
  • 1) We need a uniform and formal technique to
  • classify and specify AOP weavers.
  • 2) Programs are colored graphs (abstract syntax
    graphs)...
  • Describe aspect weaving as graph-rewriting
  • on those graphs.

13
Classes of AOP Systems
  • Script-based AOP (e.g. RG , AspectJ, InjectJ)
  • aspects are modification rules
  • Language-based AOP (e.g. D, AML )
  • aspects are specialized languages
  • Graph-rewriting-based AOP
  • rewriting rules combine aspect fragments

14
Component Aspect Graphs
15
GRS - Basics
Rewrite Rule
Derivation
Host Graph
Redex
16
AOP as GRS
  • Join Point ? Redex in Component Graph
  • Aspect Fragment ? Redex in Aspect Graph
  • Aspect Composer ? Graph Rewrite Rule
  • Weave Operation ? Direct Derivation
  • Weaver ? Graph Rewrite System with
  • a set of aspect composers,
  • a component graph, and
  • a set of aspect graphs (context-sensitive rules).

17
Example
  • Task prepend statements to method entries

class ClassDeclaration (nameName)
class ClassDeclaration (nameName)
aspectStatement Statement (placename)
aspectStatement Statement (placename)
methods
methods
method MethodDeclaration
method MethodDeclaration
entry
18
Example (2)
methods
entry
methods
methods
entry
methods
methods
19
Benefits
  • Handling of all kinds of aspects possible
  • all we need is abstract syntax
  • Uniform specification allows a classification of
    aspect weaving systems
  • Certain classes of rewrite systems guarantee
  • termination
  • confluence ( deterministic results)

20
Category I Aspect-Relating Rules
  • Edge-addition rewrite system (EARS)
  • always congruent ( terminating confluent)
  • weaving operation becomes a function
  • Ideal for simple property aspects
  • e.g. persistency, synchronization, ...

21
Category IIAspect-Additive Rules
  • if it is an eXhaustive Graph Rewrite System
    (XGRS) and does not modify the redex
  • always congruent ( terminating confluent)
  • Ideal for orthogonal aspect code
  • e.g. Adaptive Programming

22
Category IIIComponent-Modifying Rules
  • Exchange parts of components.
  • Confluence and termination are not guaranteed.
  • Indeterminism is acceptable if all normal forms
    are semantically equivalent.

23
Special CategoryAspects in Rules
  • Aspect fragments are part of the right-hand
    sides.
  • Similar to script-based AOP.
  • Ideal for aspects with finite variability.

24
Special CategoryComponent-Modifying Rules
  • Intra-component rules
  • rewrite the component graph only
  • resemble standard code motion optimizations
  • Ideal for optimizing aspect weavers.
  • e.g. RG

25
Comparison
System
terminating
deterministic
aspect graph
Aspect Fragment Matching
Aspect-relating
yes
yes
yes
Aspect-additive
if exhaustive
yes
yes
Component-modifying
if exhaustive
usually not
yes
Aspects in Rules
depends
depends
no
Intra-Component
depends
depends
no
26
Aspect Weaving is similar toProgram Optimization
  • Graph rewriting can express many program
    optimizations uniformly Aßm96.
  • Optimizations transform programs.
  • Weavers transform programs.
  • So
  • Graph rewriting can express many aspect weavings
    uniformly.

27
Generating Tools from Rewrite Specification
Program data weaving rules
Optimix
Component Code
generates
Weaver
Aspect Code
generates
Aspect Code
Aspect Code
Aspect Code
Program
28
Conclusion for Aspect People
  • GRS provide a uniform and formal way to specify
    and classify aspect weavings.
  • Tool support for weavers.
  • Open question
  • How much of AOP can be covered by this approach?

29
Conclusion for Compiler People
  • Static Weavers are compilers.
  • AOP needs more formal background
  • Architectural languages are subsumed
  • Compilers have a formal background
  • Both fields should know from each other!
  • Compilers ARE simple Weavers
  • they crosscut declarations into statements
  • Aspect Orientation will come after OOP.
  • A new kind of modularization
  • A new kind of software composition
  • Throw away OO!

30
Conclusion for Everybody
31
Think in Aspects!
Write a Comment
User Comments (0)
About PowerShow.com