uniform support for modeling crosscutting structure

23
University of British Columbia Software Practices Lab Uniform Support for Modeling Crosscutting Structure Maria Tkatchenko Gregor Kiczales Work supported by IBM and NSERC.

Upload: kirk-armstrong

Post on 30-Dec-2015

32 views

Category:

Documents


0 download

DESCRIPTION

Uniform Support for Modeling Crosscutting Structure. Maria Tkatchenko Gregor Kiczales. Work supported by IBM and NSERC. Crosscutting in a ‘UML’ Model. Advice: advise method(Subject.change(…)): “moving concern”. Crosscutting in a ‘UML’ Model. Crosscutting in a ‘UML’ Model. Role Binding: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Uniform Support for Modeling Crosscutting Structure

University of British Columbia

Software Practices Lab

Uniform Support for Modeling

Crosscutting Structure

Maria TkatchenkoGregor Kiczales

Work supported by IBM and NSERC.

Page 2: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 2

Crosscutting in a ‘UML’ Model

Advice:advise

method(Subject.change(…)):“moving concern”

Page 3: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 3

Crosscutting in a ‘UML’ Model

Page 4: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 4

Crosscutting in a ‘UML’ Model

Role Binding:

bind Line.moveBy, Point.moveBy, Point.setX, Point.setY

to Subject.change

Page 5: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 5

Crosscutting in a ‘UML’ Model

Advice:advise

method(Subject.change(…)):“moving concern”

Role Binding:

bind Line.moveBy, Point.moveBy, Point.setX, Point.setY

to Subject.change

Page 6: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 6

Related Work• [Katara, Mikkonen, ‘02]

– hierarchy of related refinements– merge sequences for composed behaviour

• [Lions et.al.,’02]– AOP in UML through use of meta-modeling in

OpenTool/UML

• [Baniassad, Clarke, ‘04]– modeler identifies and binds aspects (themes)– throughout lifecycle of project

• [Kande et.al.,’02]– first-class aspects in UML

Page 7: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 7

Terminology

• Model– as in modeling, UML, MDD, meta-model…

• JPM– as in join point model– supports the above crosscutting models

Page 8: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 8

Goals• Foundation for modeling crosscutting structure

– Compositional• different model elements• different crosscutting perspectives

– Simple• uniform• linear in number of crosscutting views (not exponential)• relatively easy to add new kind of crosscutting

• Simplifies implementation of modeling tool– directly benefits for modeling tool implementer, meta-

modeler• i.e. would it be easier to add pattern support with this approach?

– indirectly benefits modeler

Page 9: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 9

What JPM (Join Point Model) Supports That

• JPMs are fundamental mechanism for support of crosscutting

• A simple JPM for UML– (for now, taking freedom to change the UML

meta-model)

• JPMs have three parts [Masuhara, ‘03]• Join points• Identifying join points• Semantic effect

Page 10: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 10

JPM

• Join points– model elements– Class, Method, Field, Advice in Class Diagram– Method Call, Sequence (focus of control) in Sequence Diagram– uniform, but 2 JPs per crosscutting interaction

• Identifying join points– signatures, type patterns, pointcuts…

• Semantic effect– each has particular declaration semantics

• declare a class, method, sequence, advice…

• Weaver– based on Eclipse EMF framework– collects crosscutting among the elements– what elements crosscut each other?

Page 11: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 11

Meta-Model

FieldDecl MethodDecl AdviceDecl

ClassMemberDeclClassDecl SequenceDecl MethodCallDecl

ClassDiagramMemberDecl SequenceDiagramMemberDecl

Declaration

JoinPoint

crosscutByList: List<JoinPoint>

Page 12: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 12

Crosscutting in the weaver

(<jp>, <jp>, <jp>, <jp>, <jp>, <jp>, …)

Page 13: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 13

Crosscutting in the weaver

(<jp>, <jp>, <jp>, <jp>, <jp>, <jp>, …)

Page 14: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 14

Crosscutting in the weaver

(…<jp>, …)

(… <jp>, …)

• every element has

crosscutByList

• two join points per

crosscutting interaction

Page 15: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 15

Crosscutting in the weaver

Role Binding:

bind Line.moveBy, Point.moveBy, Point.setX, Point.setY

to Subject.change

(<jp>, <jp>, <jp>, <jp>, <jp>, <jp>, …)

• same thing happens

for all kinds of cc

Page 16: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 16

Crosscutting in the weaverAdvice:advise

method(Subject.change(…)):“moving concern”

Role Binding:

bind Line.moveBy, Point.moveBy, Point.setX, Point.setY

to Subject.change

• how is advice

affected by role

binding?

(<jp>, <jp>, <jp>, <jp>, <jp>, <jp>, …)

(<jp>, <jp>, <jp>,…)

Page 17: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 17

Crosscutting in the weaverAdvice:advise

method(Subject.change(…)):“moving concern”

Role Binding:

bind Line.moveBy, Point.moveBy, Point.setX, Point.setY

to Subject.change

• how is advice

affected by role

binding?

(<jp>, <jp>, <jp>, <jp>, <jp>, <jp>, …)

(<jp>, <jp>, <jp>,…)

( <jp>, <jp>,…)

Page 18: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 18

Implementation• Simple staged approach to weaving

1. role binding2. inter-type declarations3. sequence diagrams4. advice

• Simplifies semantic interactions– advice depends on roles, but not vice versa

• Each pass records– relevant semantic information

• type and method inheritance tables– additions to crosscutByList of each JP

Page 19: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 19

Use of woven information

• Question: how to find out whether an element has advice applied to it?

boolean hasAdvice(Decl decl) {

for (Decl otherDecl:

decl.getCrosscutByList())

if (otherDecl instanceof AdviceDecl)

return true;

return false;

Page 20: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 20

Use of woven information

• Question: how to build the complete (possible) cflow of a call C

for C and any calls in its sequence diagram, repeat containedCalls(call)

List containedCalls(Call c1) {List result;

for (Decl c2: c1.getCrosscutByList()) if (c2 instanceof Call && c1.getSignature().matches(c2.getSignature()) { result.add(c2); result.addAll(containedCalls(c2));

} }

Page 21: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 21

Status of work

• Done so far– JPM design– UML meta-model– UML language– Implementation: weaver

• Prototype• Modular

– Simplified: reasonable subset of UML• no methodReceipt, methodReturn join points in

Sequence Diagrams• no other diagrams

Page 22: Uniform Support for Modeling Crosscutting Structure

AOSD 2005 22

Summary

• Simple approach to modeling crosscutting– for existing and new kinds of crosscutting

• Simple and modular implementation

• Approach consists of– JPM– extension to the UML meta-model– weaver

Page 23: Uniform Support for Modeling Crosscutting Structure

University of British Columbia

Software Practices Lab

Uniform Support for Modeling

Crosscutting Structure

QUESTIONS?