Master - PowerPoint PPT Presentation

About This Presentation
Title:

Master

Description:

Allows designers to see imbalance of concerns. Designers can fix these imbalances with appropriate features that address appropriate concerns ... – PowerPoint PPT presentation

Number of Views:1273
Avg rating:3.0/5.0
Slides: 70
Provided by: valueds225
Learn more at: https://www2.ccs.neu.edu
Category:
Tags: master

less

Transcript and Presenter's Notes

Title: Master


1
Masters Thesis DefenseAspectual Concepts
  • John J. Sung

2
AspectJ from PARC
Aspect-oriented tools referred to in this talk
3
Static Scattering and Tangling
  • aspecti is scattered across many classes (i
    1,2,3)
  • class X tangles aspects 1, 2 and 3

class A consisting of three aspects
aspect1
aspect2
aspect3
class diagram
Class X
classes for aspect1
classes for aspect3
classes for aspect2
Adding to classes
4
Dynamic Scattering and Tangling
  • Each aspect (colors) is scattered across many
    classes (shapes)
  • Class tangles all three aspects

program execution involving three aspects
(colors r b g)
this(s)
f(..)
target(t)
program call tree (objects executing method
calls)
Enhancing calls
t.f(..)
classes
At those calls the aspect enhances the behavior
5
subcomputation join points related to
traversing through the objects guided by
traversal specification and class graph.
6
From DJ to AspectJ
DJ
AspectJ
  • Pointcut
  • set of execution points of any method,
  • rich set of primitive pointcuts this, target,
    call, set operations
  • where to enhance
  • Advice
  • how to enhance
  • Visitor method sig.
  • set of execution points of traversals
  • specialized for traversals (nodes, edges)
  • where to enhance
  • Visitor method bodies
  • how to enhance

7
Outline
  • Motivation
  • JPM and Demeter Concepts
  • Demeter integrated with AspectJ (DAJ)
  • DAJ Semantics/Syntax
  • DAJ System Architecture
  • Four Graph Model of Programs (4GMP)
  • Conclusion

8
Motivation
  • Aspect Oriented Software Development Gaining
    Momentum
  • 1st International Conference on AOSD
  • AspectJ, DemeterJ, ConcernJ, HyperJ, etc.
  • AOSD is Relatively Young
  • DemeterJ 1989
  • AspectJ 1997

Karl J. Lieberherr Demeter C 1989 DemeterJ 1996
9
Questions
  • What are the fundamental concepts behind AOSD?
  • How are these concepts related?
  • Can these concepts be mixed?
  • What are the fundamental problems that software
    language features attempt to solve?

Karl J. Lieberherr How can these concepts be
combined?
10
Joinpoint Model (JPM)
  • Fundamental Concepts
  • Joinpoint, Pointcut, Advice, Aspect, Introduction
  • Concepts applied to call graph in AspectJ
  • Building or Construction Metaphor

Karl J. Lieberherr Also to class graph
introductions
11
Construction Metaphor
Karl J. Lieberherr Of structures constructed
from building
  • Concepts in JPM create an image of constructed
    structures from building blocks

12
AspectJ Abstraction of Programs
Program
gt
Call Graph
Pointcuts
Advices


13
AspectJ Abstraction of Programs
c1
bar
b1.foo()
int x
within(bar)
aspect
foo() x 0 if (x lt 0) throw KException
before() within(bar)
14
Another View
AspectJ
Advice
advice body
pointcut
join point
Java Program
15
Demeter
  • Fundamental Concepts
  • Class Graph, Strategy, Visitor, Advice
  • Concepts applied to data structures, i.e. class
    graph
  • Journey Metaphor

16
Journey Metaphor
  • Concepts in Demeter create an image of a person
    on a journey

17
Demeter Abstraction of Programs
Program
gt
Visitor Advices
Strategy Graph
Class Graph


18
Demeter Abstraction of Programs
Class Graph
Strategy Graph
Traversal Graph
Visitor Advices
before(..)
gt
after(..)
before(..)
19
Mixing Concepts
  • Application of JPM on Demeter
  • Class graph is built of classes and edges
  • Joinpoints become the points along traversals
  • Advices are executed at these joinpoints

20
Mixing Concepts
Karl J. Lieberherr Advices with a
  • Application of Demeter on JPM
  • CPU is the global visitor
  • Advice with a pointcut are Demeter advices for
    the global visitor
  • Visitor is traversing the Dynamic Call Graph

Karl J. Lieberherr This continues to be
non-convincing.
21
Demeter AspectJ (DAJ)
  • Uses AspectJ as the backend compiler
  • Uses DJ to generate Class Graph, Traversal Graph
  • Generates the AspectJ implementation of the
    traversal
  • Defines a traversal specification language
  • Implemented using DemeterJ
  • Application of JPM on Demeter

22
Traversal Specification Language
  • Designed to have similar syntax to DJ and AspectJ
  • Allows users to specify Class Graph, Traversal,
    and Visitor
  • Generates AspectJ implementation of traversals

23
Class Graph Specification
  • Default Class Graph
  • ClassGraph cgvar
  • Class Graph Slice
  • ClassGraph cgvar new ClassGraph(cg,
    strategy)

24
Visitor Specification
  • Uses Java Reflection to obtain method signatures
  • Recognized methods are
  • around, before, after, start, finish, returnValue
  • Visitor Declaration
  • Visitor visitorClass

25
Traversal Specification
  • Default Traversal Specification
  • declare traversal tvar strategy
  • Traversal with Class Graph
  • declare traversal tvar(cgvar) strategy
  • Traversal with Visitor
  • declare traversal tvar(cgvar, visitorvar)
    strategy

26
Aspect Specification
aspect aspectName class graph declarations
traversal declarations visitor declarations
27
What DAJ Generates
  • For each default and class graph slice traversal
  • method void tvar() for the source node of the
    traversal strategy
  • For each traversal with visitor
  • method void tvar() for the source node of the
    traversal strategy
  • method void tvar(visitorClass) for the source
    node of the traversal strategy
  • Appropriate AspectJ Advices for each advice in
    visitorClass

28
A Simple Basket Example
class Basket Basket(Fruit _f, Pencil _p)
f _f p _p Basket(Fruit _f, Fruit _f2,
Pencil _p) f _f f2 _f2 p _p
Fruit f, f2 Pencil p class Fruit
Fruit(Weight _w) w _w Weight
w class Orange extends Fruit
Orange(Color _c) super(null) c_c
Orange(Color _c, Weight _w) super(_w) c _c
Color c class Pencil class Color
Color(String _s) s _s String s class
Weight Weight(int _i) i _i int i
int get_i() return i
29
A Simple Basket Example
Basket
f, f2
p
Fruit
Pencil
Orange
w
c
Weight
Color
int i
s
String
30
BasketVisitor
class BasketVisitor int total public
void start() total 0 public int
returnValue() return total
void before(Weight w) total w.get_i()

31
Basket Traversal
aspect BasketTraversal ClassGraph default
ClassGraph myClassGraph new
ClassGraph(default, "from Basket to ")
Visitor BasketVisitor declare traversal
t1(myClassGraph,BasketVisitor) "from Basket
to Weight" declare traversal
t2(myClassGraph,BasketVisitor) "from Basket
via Orange to Weight"
32
Basket Main
Karl J. Lieberherr Visitor object generation not
automatic. More flexibility this way.
class BasketMain static public void
main(String args) throws Exception Basket
b new Basket(new Orange(new Color("orange"),
new Weight(5)), new Fruit( new
Weight(10)), new Pencil()
) BasketVisitor bv new BasketVisitor() b.t1
(bv) int totalWeight bv.returnValue() System
.out.println("Total weight of basket "
totalWeight) b.t2(bv) totalWeight
bv.returnValue() System.out.println("Total
weight2 of basket " totalWeight)
33
Generated Code for Visitor
public aspect BasketTraversal static
BasketVisitor t1_visitor public void
Basket.t1(BasketVisitor v) t1_visitorv
t1_visitor.start() t1()
before(Weight host) call(public void t1())
target(host) t1_visitor.before(host)
void Basket.t1() t1_copy0()
Karl J. Lieberherr What is this?
34
Basket Class Graph
Basket
f, f2
p
Fruit
Pencil
Orange
w
c
Weight
Color
int i
s
String
35
Generated Code for Traversal
// traversal t1 source Basket -gt target
Weight with public void
Basket.t1_copy0() if (f ! null)
t1_copy0_crossing_f() if (f2 ! null)
t1_copy0_crossing_f2() public void
Basket.t1_copy0_crossing_f() f.t1_copy0()
public void Basket.t1_copy0_crossing_f2()
f2.t1_copy0() public void Fruit.t1_copy0()
if (w ! null) t1_copy0_crossing_w()
public void Fruit.t1_copy0_crossing_w()
w.t1_copy0() public void Weight.t1_copy0()
public void Orange.t1_copy0()
super.t1_copy0() pointcut pointcut_t1()
call(public void t1()) before ()
pointcut_t1 () System.out.println(thisJoinP
oint)
36
System Architecture
Karl J. Lieberherr How are stubs different from
traversals?
  • DAJ Main
  • Parses command line arguments
  • Manages the DAJ code generation phases
  • Stub Generation
  • Generates stubs for traversal methods
  • Traversal Generation Compilation
  • Compiles using ajc the stubs, user code, and
    CreateClassGraph.java

37
System Architecture
  • Traversal Generation
  • Uses DJ, Java Reflection, and DemeterJ to
    generate AspectJ traversal code
  • Traversal Compilation
  • Compiles the generated traversal code with user
    code

38
System Architecture
Karl J. Lieberherr Do not mention shell scripts
Stub Generation
method call
Traversal Generation Compilation
shell
DAJ Main
shell
Traversal Generation
shell
Traversal Compilation
39
DAJ Process
Karl J. Lieberherr CreateClassGraph.java is
provided by DAJ Very confusing naming What
information is generated by each box input files
and output files and who provides them
Traversal Files
Stub Generation
Traversal Generation Compilation
Generated Stubs
Class Files
Traversal Implementation
Traversal Generation
CreateClassGraph.java
User Code
Traversal Compilation
Class Files
40
Future Improvements
Karl J. Lieberherr Correctly??
  • http//www.ccs.neu.edu/research/demeter/DAJ
  • Two syntax supported
  • DJ/Java like style
  • AspectJs declare syntax
  • Handle Collections
  • Traversal through Java Collections
  • Handle interfaces
  • Traversal correctly for interfaces

41
Four Graph Model of Programs
  • Merging of graphs in Demeter and JPM
  • Model for creating relationships between
    different features
  • AOP feature analysis
  • Only a proposal and needs lots of work

42
4GMP
Program
Compile-Time
Runtime
Executable
Process
Object Graph
Class Graph
Data Structures
Static Call Graph
Dynamic Call Graph
Algorithm
43
Compile-Time vs. Run-Time
  • Compile-time graphs specify all possible run-time
    graphs
  • The computer system combines the compile-time
    graph with input to generate the run-time graph
  • In a way, the compile-time graph has factored out
    the commonalities within the run-time graph
  • Factorizational Concern

44
Factorizational Concern
Specification
Input
Processor
Output
45
Factorizational Concern

46
Factorizational Concern Examples
  • Functions that are used multiple times
  • Inherited methods and data members
  • Parser generation for DemeterJ
  • Wildcards for pointcut designators in AspectJ
  • Traversal generation in DAJ

47
Data Structure vs. Algorithm
  • One of many ways of slicing up a program
  • data flow / control flow
  • Layering
  • Modules
  • It does not change the amount of code that one
    has to write
  • Large programs are a fact of life and it needs to
    be organized in some way
  • Organizational Concern

48
Organizational Concern
49
Organizational Concern Examples
  • Functions that are called only once
  • Non-inherited methods and data members
  • Open classes in DemeterJ
  • Introductions in AspectJ

50
Factorizational/Organizational Concerns
  • Most programming language features have both
    characteristics depending on their uses
  • Both are needed to cope with the problem of
    programs growing ever larger

51
Concern Relationship Diagram
  • We may approximate relationships between features
    and the graphs in 4GMP

52
Concern Relationship Diagram
FC Factorizational Concern
Concern Relationship
OC Organizational Concern
FC
Class Graph
Object Graph
OC
OC
Static Call Graph
Dynamic Call Graph
FC
53
AspectJ CRD
FC Factorizational Concern
OC
OC Organizational Concern
Aspect
SP Specification Feature
Pointcut
OC
Advice
SP
FC
Class Graph
Object Graph
FC
FC
OC
SP
SP
OC
OC
Join Point
OC
SP
SP
Static Call Graph
Dynamic Call Graph
Introduction
FC
OC
54
DemeterJ CRD
Class Dictionary
FC Factorizational Concern
OC Organizational Concern
FC
Strategy Graph
FC
Class Graph
Object Graph
FC
FC
FC
OC
OC
Traversal Graph
Static Call Graph
Dynamic Call Graph
FC
OC
FC
Visitor
Advice
OC
55
Ideal CRD
FC
FC
Feature
Feature
OC
OC
Feature
Feature
56
Ideal CRD
FC
FC
Feature
Feature
OC
OC
Feature
57
What Good Are CRDs?
  • CRD is a higher level feature map
  • Allows designers to see imbalance of concerns
  • Designers can fix these imbalances with
    appropriate features that address appropriate
    concerns
  • Programming Feature Analysis!

58
DemeterJ Feature Analysis
  • CRD has many FC relations
  • Possibly add features with OC relations to Class
    Dictionary, Strategy Graph, Traversal Graph

59
DemeterJ CRD
Class Dictionary
FC Factorizational Concern
OC Organizational Concern
OC
FC
Strategy Graph
FC
Class Graph
Object Graph
FC
FC
OC
OC
Traversal Graph
Static Call Graph
Dynamic Call Graph
FC
OC
FC
Visitor
Advice
OC
60
AspectJ Feature Analysis
  • CRD has many OC relations
  • Possibly add features with FC relations to Aspect
    and Introductions

61
AspectJ CRD
FC Factorizational Concern
OC
OC Organizational Concern
Aspect
SP Specification Feature
Pointcut
OC
Advice
SP
FC
Class Graph
Object Graph
FC
FC
OC
SP
SP
OC
OC
Join Point
OC
SP
SP
Static Call Graph
Dynamic Call Graph
Introduction
FC
OC
62
Problems With CRDs
  • In what scope should one create CRDs?
  • Should AspectJ and DemeterJ CRDs account for
    features in Java?
  • Most features have FC and OC
  • How do I deal with these features?

63
Other Types of Concerns
  • Interface Concerns
  • When two entities within a program need to
    communicate
  • Abstract classes in OOP
  • Interfaces in Java
  • Specification Concerns
  • Things that programmers want to specify or
    reference
  • Java reflections
  • AspectJ joinpoints

64
Questions
  • What are the fundamental concepts behind AOSD in
    Demeter and AspectJ?
  • How are these concepts related?
  • Can these concepts be mixed?
  • What are the fundamental problems that software
    language features attempt to solve?

65
Conclusions
  • Metaphors used in Demeter and JPM
  • Construction and Journey Metaphors
  • Usage of one or the other depends on the users
    and application
  • Can describe each other
  • Mixable

66
Conclusions
  • DAJ
  • Mixing Demeter with AspectJ concepts
  • Uses DJ, DemeterJ and AspectJ
  • www.ccs.neu.edu/research/demeter/DAJ

67
Conclusions
  • Four Graph Model of Programs
  • Merges graphs in Demeter and AspectJ
  • Factorizational/Organizational Concerns
  • Concern Relationship Diagram
  • Programming Feature Analysis
  • Needs lots of work!

68
Future Direction
  • Try mixing other tools
  • ComposeJ, HyperJ, etc.
  • Feature analysis of other tools and concepts
  • Investigate other types of concerns
  • Relationship between concerns relationships in
    features with HCI and SE

69
References
  • www.ccs.neu.edu/research/demeter/DAJ
  • www.ccs.neu.edu/research/demeter/DemeterJava
  • www.ccs.neu.edu/research/demeter/DJ
  • www.aspectj.org
Write a Comment
User Comments (0)
About PowerShow.com