Better Separation of Crosscutting Concerns with Aspectual Components - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Better Separation of Crosscutting Concerns with Aspectual Components

Description:

Can be done in plain Java using DJ library ... 'Pelican') ABB Aspect - Architecture. Users of the object only. deal with the Aspect's ' ... – PowerPoint PPT presentation

Number of Views:137
Avg rating:3.0/5.0
Slides: 49
Provided by: karllie
Learn more at: https://www2.ccs.neu.edu
Category:

less

Transcript and Presenter's Notes

Title: Better Separation of Crosscutting Concerns with Aspectual Components


1
Better Separation of Crosscutting Concerns
withAspectual Components
  • Karl Lieberherr
  • College of Computer Science
  • Demeter Team
  • Northeastern University, Boston
  • www.ccs.neu.edu/research/demeter

2
Overview
  • Aspect-Oriented Software Development (AOSD)
    Crosscutting concerns, controlling tangling and
    scattering
  • Example Collect
  • Aspectual Components DJ
  • Comparison to AspectJ
  • Summary

3
Messages
  • AOSD is useful
  • Adaptive Programming mechanisms must be used to
    properly express traversal-related aspects. Can
    be done in plain Java using DJ library
  • Present ABB Aspects can be viewed as a reusable
    function library

4
The MIT Technology Review (Jan./Feb. 2001 issue)
  • Ten emerging technologies that will change the
    world
  • Untangling Code - Aspect-Oriented Programming
    (AOP)
  • Data Mining
  • Micro Fluids
  • Robot Design
  • ...

5
Quote MIT Technology Magazine
  • The idea of aspects has been around for many
    years and with many different names. It is called
    adaptive programming at Northeastern University,
    and subject-oriented programming at IBM,

6
From Crista Lopes PhD thesis (NU/Xerox PARC)
Instead of writing this
7
AOSD not every concern fits into a component
crosscutting
Goal find new component structures that
encapsulate rich concerns
8
AOSDAspect-Oriented Software Development
  • The job of an AOSD (Aspect-Oriented Software
    Development) technology, a special case of SOC,
    is to turn a tangled and scattered description
    (at analysis, design or implementation level) of
    a crosscutting concern into a well-modularized
    description of a concern.

9
Aspect-Oriented Software Development (AOSD)
  • Turn tangled and scattered descriptions of a
    crosscutting concern into a well-modularized
    description of a concern.
  • Analysis, design and implementation techniques.

10
AOP (Aspect-Oriented Programming)
  • Turn tangled and scattered implementation of a
    crosscutting concern into a well-modularized
    implementation of a concern.
  • Tools AspectJ, DJ, DemeterJ, etc.

11
Features of AOP languages
  • AOP languages have the following main elements
  • a join point model (JPM) wrt base PL
  • a specification language for expressing sets of
    join points (JPS)
  • a means of specifying behavior involving join
    points (BJP)
  • encapsulated units combining JPS and BJP (CSB)
  • method of attachment of units to base program (AU)

JPS and BJP are sometimes overlapping. JPS might
already define an initial behavior plus a set of
join points in that behavior.
12
Comparing
  • ABB Aspects
  • AspectJ
  • DemeterJ
  • DJ
  • AspectC
  • Aspectual Collaborations
  • D (COOL, RIDL)
  • BETA
  • RG

13
AOP
  • Example Logging record every operation an
    application performs
  • When adding a new operation to this application,
    always put a trace statement in
  • Keeping track of crosscutting concerns is
    error-prone

14
AOP
  • Crosscutting concerns, when implemented in an
    ad-hoc way, lead to a lot of tangling and
    scattering in the program.
  • Goal of AOP is to control the tangling and
    scattering in the program.

15
Scattering count number of components to which
color goes
ordinary program
better program
structure-shy functionality
CM1
Concern 1
structure
CM2
Concern 2
CM3
synchronization
Concern 3
16
Aspect-Oriented ProgrammingExample
  • Separating the following crosscutting concerns
  • Object Structure concern (JAXB, optional package
    for Java 2 platform, XML schema UML class graph)
  • Traversal-related concerns traverse a group of
    connected objects and execute code attached to
    nodes and edges of object graph (advice).
  • separate traversals and advice
  • Those two kinds of concerns appear frequently.

17
Crosscutting in Equation System
overall graph object structure green graph
traversal purple advice
usedThings from EquationSystem through
Expression to Variable
equations
esEquationSystem
elsEquation_List
new HashSet
i1Ident
lhs
e1Equation
v1Variable
Object graph
rhs
elsExpression_List
c1Compound
i2Ident
v2Variable
a1Add
add
i3Ident
v3Variable
add
18
What is a component?
  • any identifiable slice of behaviour that delivers
    a meaningful service, involving in general
    several participants,
  • used via well-defined interfaces,
  • formulated for an ideal ontology
  • can be deployed into a concrete ontology,
  • is subject to composition by 3rd parties
    (black-box reuse)
  • is subject to refinement by 3rd parties
    (white-box reuse)

19
What is an Aspectual Component
Class Graph
P1
P3
P2
Behavior Definition
P
P1
before / around
provided everything public

after
written to the CG similar to an OO
program is written to a concrete class graph

...
P3
enhancements before/around/after
...
before / around
after
20
Connection to ABB Aspects
Class Graph
P1
Behavior Definition
P
P1
Claim ABB aspects have only one participant
...
21
Mapping Popular Functions
with Anuj Shah
22
ABB Aspects
  • Encapsulate popular functions independent of any
    specific class hierarchy

23
ABB Aspect - Architecture
24
ABB Aspects My View
  • Provided interface
  • popular functions go here
  • Required interface
  • functions to be implemented by personifying class
  • Private functions
  • no visibility either upstream or downstream
  • Role-specific attributes
  • to keep the roles state
  • Constructor
  • to initialize the role-specific attributes

25
Personality - Definition Syntax
26
by Anuj Shah
  • FlyControl
  • private myAspect as ABBAspect
  • private myExpectedControl as ExpectedFlyControl
  • public sub fly(altitude as Integer)
  • call cmdTakeOff_Click
  • dim index as Integer
  • for index 1 to altitude
  • call cmdAscend_Click
  • next
  • end sub
  • private sub cmdAscend_Click()
  • myExpectedControl.Ascend
  • end sub
  • ...

27
by Anuj Shah
  • ExpectedFlyControl
  • public sub TakeOff()
  • MsgBox I am taking off now!
  • end sub
  • public sub Ascend()
  • MsgBox I am Ascending now!
  • end sub

28
M1 Equation System
EquationSystem
equations
Equation_List
Ident

Variable
lhs
Equation
Numerical
rhs
Expression_List
Simple
args
Expression

op
Add
Compound
29
Collect Things
System EquationSystem Definition
Equation Body Expression Thing
Variable
definedThings
System

Thing

usedThings


Definition
Body
definedThings from System bypassing Body to
Thing usedThings from System through Body
to Thing from System
constraint to Thing
30
M1 Equation System
definedThings from EquationSystem bypassing
Expression to Variable
EquationSystem
equations
Equation_List
Ident

lhs
Equation
Variable
Numerical
rhs
Simple
args
Expression_List
Expression
S
T

op
Add
Compound
D
B
31
M1 Equation System
usedThings from EquationSystem through
Expression to Variable
EquationSystem
equations
Equation_List
Ident

lhs
Equation
Variable
Numerical
rhs
Simple
args
Expression_List
Expression
S
T

op
Add
Compound
D
B
32
Aspectual Component
  • component COLLECT
  • participant Source
  • expected static ClassGraph cg
  • public HashSet collect(String constraint)
  • String id from Target to
    edu.neu.ccs.demeter.Ident
  • Visitor v new Visitor()
  • HashSet return_val new HashSet()
  • void before(Target v1)
  • return_val.add(cg.fetch(v1, id) )
  • public Object getReturnValue()return
    return_val
  • Source.cg.traverse(this,
  • from Source constraint to Target,
    v
  • participant Target

33
Aspectual Component
  • Find appropriate class graph and traversals for
    task at hand
  • Simplify from graph with 11 nodes to graph with 4
    nodes to graph with two nodes.

34
Adapter part
  • // EquationSystem class graph
  • attach COLLECT
  • EquationSystem Source with
  • provide EquationSystemcg to
  • Sourcecg
  • Variable Target

35
simulate in pure Java using DJ
  • class System
  • String id from Thing to edu.neu.ccs.demeter.I
    dent
  • HashSet collect(ClassGraph cg, String
    constraint)
  • Visitor v new Visitor()
  • HashSet return_val new HashSet()
  • void before(Thing v1)
  • return_val.add(cg.fetch(v1, id) )
  • public Object getReturnValue()return
    return_val
  • cg.traverse(this,from Systemconstraintto
    Thing, v)
  • return (HashSet)v.getReturnValue()
  • HashSet defined(ClassGraph cg)
  • return (HashSet) this.collect(cg, bypassing
    Body )
  • HashSet used(ClassGraph cg)
  • return (HashSet) this.collect(cg, through
    Body )

green traversal black bold structure purple
advice red parameters
36
Concepts needed(DJ classes)
  • ClassGraph
  • Strategy ( Java String traversal strategy)
  • Visitor

37
ABB versus AOSD view of aspects
  • Compare ABB view of aspects with views of AOSD
    community.

38
ABB Aspects
  • page 4 Each aspect is modeled separately. AOSD
    Each aspect needs its own class graph and
    behavior expressed for classes in class graph.
  • page 5, figure 4 need to customize an aspect.
    page 19 Many aspects provide some degree of
    configurability AOSD adapters.

39
ABB Aspects
  • page 4 an aspect object is a container of
    references to implementations of different
    aspects. AOSD an object may play multiple roles.
  • page 5 An aspect is implemented by an aspect
    system which stores, manages and presents its
    information in an optimal way. AOSD different
    implementations s/d

40
Comparison
  • ABB aspect
  • one participant
  • aspect adds data members or methods to an object
  • AOSD aspect
  • several participants
  • aspect adds data members or methods to an object
  • enhances existing methods of an object

41
Object exists in many structures
  • ABB from page 6 Depending on what aspect we
    look at, the same entity fits naturally in
    several different structures.
  • AOSD Object plays several roles
  • each role playing places object in structure of
    corresponding collaboration

42
Object exists in many structures
  • ABB Example (from page 7)
  • functional structure
  • location structure
  • batch structure
  • AOSD Object plays several roles
  • each role playing places object in structure of
    corresponding collaboration

43
Perspectives/Views/Aspects
  • Aspect a well modularized cross-cutting concern
  • Perspective/view a special kind of aspect that
    adds members to a group of objects
  • page 4 each object can be described from several
    different perspectives

44
Attach aspects dynamically
  • page 8 when an instance of an object type is
    created, it inherits the aspects that are
    defined in the object type. You can add aspects
    to a specific instance.
  • AOSD composite aspects dynamically add aspects
    to an object.

45
How ABB aspects fit inan open object model
  • Join point model
  • dynamic objects
  • Express sets of join points
  • enumerate objects
  • Express code to be added at join points
  • members

open objects
46
Summary
  • AOP getting a lot of attention. Addresses an
    important problem how to program crosscutting
    concerns.
  • AP is about relieving the programmer from the
    details of a concern traditionally from the
    structural concern.
  • DJ support Adaptive and Aspect-Oriented
    Programming for traversal concerns in Java.

47
Summary
  • We view components as slices of behavior
  • Aspectual components
  • reconcile between functional and object
    decomposition
  • add new behavior and modify existing behavior
  • are a good model for AOP

48
Feedback
  • Alternative way to sell ABB Aspects
  • reusable function repository
  • ABB aspect improvements
  • better decoupling between aspects
  • more flexible expected methods
  • use traversal-strategies for object navigation
  • ABB aspect extensions
  • multiple participants
  • aspectual methods
Write a Comment
User Comments (0)
About PowerShow.com