Crosscutting Effective Views Kris De Volder Ed Mc

  • Slides: 24
Download presentation
Crosscutting Effective Views Kris De Volder Ed Mc. Cormick Doug Janzen University of British

Crosscutting Effective Views Kris De Volder Ed Mc. Cormick Doug Janzen University of British Columbia Software Practices Lab

Some Definitions Crosscutting Views Two views are crosscutting when program elements that are scattered

Some Definitions Crosscutting Views Two views are crosscutting when program elements that are scattered in one view are modularized in the other view and vice versa. 2

Some Definitions Effective Views which can be manipulated to produce changes in a program.

Some Definitions Effective Views which can be manipulated to produce changes in a program. effective (typically) non-effective analyze Source Files generate view Program Representation Tool Views 3

Crosscutting is Symmetric A crosscuts B B crosscuts A Two points of view… Who

Crosscutting is Symmetric A crosscuts B B crosscuts A Two points of view… Who is crosscutting whom? Classes crosscut aspects Aspects crosscut classes 4

Bad News for Aspects? Crosscutting is symmetric so… modularized aspects scattered classes Objected-oriented view

Bad News for Aspects? Crosscutting is symmetric so… modularized aspects scattered classes Objected-oriented view classes + aspects aspect is scattered Aspect-oriented view classes - aspects aspect is modular 5

Bad News for Aspects? Crosscutting is symmetric so… modularized aspects scattered classes Objected-oriented view

Bad News for Aspects? Crosscutting is symmetric so… modularized aspects scattered classes Objected-oriented view classes + aspects class is modular (aspect are scattered) Aspect-oriented view classes - aspects class is scattered (aspects are modular) Q: What is “best” modular aspects or modular classes? 6

Maybe Tools Can Help? With IDE tooling (AJDT) you can edit the AO view

Maybe Tools Can Help? With IDE tooling (AJDT) you can edit the AO view and still see the OO view! What is in the source code classes What the IDE shows you aspects advice applies here 7

The IDE View is Non-Effective Looking at the classes you can see where the

The IDE View is Non-Effective Looking at the classes you can see where the aspects apply… advice applies here but you cannot change it there. 8

Research Hypothesis It is useful for AO developers to be able to work with

Research Hypothesis It is useful for AO developers to be able to work with multiple views on the system that are effective and crosscutting at the same time. 9

Research Question How can we design and implement tools that support crosscutting effective views?

Research Question How can we design and implement tools that support crosscutting effective views? See and change system from this point of view simultaneously See and change system from this point of view 10

Past Work The Decal prototype [Janzen&De. Volder 2004] – motivation for research hypothesis –

Past Work The Decal prototype [Janzen&De. Volder 2004] – motivation for research hypothesis – answers research question for limited language: • only inter-type declarations • no pointcuts or advice – exploration of part of the design space • mix of tool and language • based on notion of Virtual Source Files [Chu-Carol et. al 2002] 11

Current Work [De. Volder&Mc. Cormick ? ? ] Research question: How can we make

Current Work [De. Volder&Mc. Cormick ? ? ] Research question: How can we make this view … edit pointcut directly from here … an effective view for editing pointcuts. 12

Current Work [De. Volder&Mc. Cormick ? ? ] Motivation Why do we want to

Current Work [De. Volder&Mc. Cormick ? ? ] Motivation Why do we want to make this view … … an effective view for editing pointcuts? 13

Motivating Example Adding sound effects to the “spacewar” game What an OO programmer does

Motivating Example Adding sound effects to the “spacewar” game What an OO programmer does What an AO programmer does • Develop a sound playing utility (SPU) • Analyze the base code: find the “joinpoints”. • Develop sound playing aspect (SPA) • Analyze the base code: find the joinpoints. • When joinpoint found: insert a call there. • When joinpoint found: go to SPA and edit pointcut expression. Comparable work which is harder? class Sound. Player. Utility { void play. Ship. Fire. Sound() { … } void play. Player. Dies. Sound() { …} … } aspect Sound. Player. Aspect { pointcut ship. Fire() : …fill in later. . pointcut player. Dies() : …fill in later. . after ship. Fire() : { play(“ship. Fires. snd”); } … 14

Motivating Example Which is harder? What an OO programmer does • When a joinpoint

Motivating Example Which is harder? What an OO programmer does • When a joinpoint is found: insert a call there. Simple and direct • edits occur where information is discovered. • add a call directly at the intended joinpoint. What an AO programmer does • When a joinpoint is found: go to aspect and edit pointcut expression. More indirect • edits occur at a different place than where relevant information is discovered. • must verify that pointcut matches at the intended joinpoint 15

Approach: Pointcut by Example Manipulate pointcuts by means of “example” joinpoint (shadows) the user

Approach: Pointcut by Example Manipulate pointcuts by means of “example” joinpoint (shadows) the user points at directly in the code. Right click here and select “add jp” menu. Right click here and select “remove jp”. pointcut gun. Fire() : withincode(void Ship. fire()) && call(Bullet. new(Game, double, doubl Work/think directly, in terms of base code, but you still get an aspect. 16

More Tricky than It Seems Editing Semantics The disjointness property: every element has at

More Tricky than It Seems Editing Semantics The disjointness property: every element has at most one location/representation within a particular view. disjointness property broken ambiguity in editing semantics [Janzen&De. Volder 2004] 17

Pointcuts / Advice are Tricky … break the disjointness property: a pointcut at one

Pointcuts / Advice are Tricky … break the disjointness property: a pointcut at one location here … …can map to many locations here call (* Shape+. get*()) Aspect-oriented view Object-oriented view How does this give rise to ambiguity? How do we deal with that? 18

How Does Ambiguity Arise? Example: PCD : = execution (* Shape+. get*()) class Point

How Does Ambiguity Arise? Example: PCD : = execution (* Shape+. get*()) class Point extends Shape { int x, y; public int get. X() {… } public int get. Y() {… } Perform “delete joinpoints” here. What does it mean? marker only an instance of bigger set of markers representing the PCD. operation is ambiguous if … applicable to different subsets of PCD markers. 19

How is Ambiguity Resolved Example: PCD : = execution (* Shape+. get*()) Perform “delete”

How is Ambiguity Resolved Example: PCD : = execution (* Shape+. get*()) Perform “delete” here class Point extends Shape { int x, y; public int get. X() {… } public int get. Y() {… } Means… rewrite the PCD: PCD’ : = PCD && ! Marker. PCD (and possibly simplify / canonicalize the PCD!) ? => Ambiguity is resolved by deciding what Marker. PCD stands for. 20

How is Ambiguity Resolved Exactly how this should work is undecided still but •

How is Ambiguity Resolved Exactly how this should work is undecided still but • A “Query by example” dailog-based approach • Determine “most specific PCD” to prefil the dialog. • Use PCD semantics to disable meaningless options. package drawing. shapes class Point extends Shape { public int get. X() {… } delete Most. Specific. PCD : = execution(public int drawing. shapes. Point. get. X()) Delete Joinpoints: method execution class: drawing. shapes public name: get. X class: Point returns: int args: () OK 21

Pointcut By Example Current status – Developing a prototype Eclipse plug-in – Only started

Pointcut By Example Current status – Developing a prototype Eclipse plug-in – Only started thinking about all the issues Many open questions – – – – how useful/necessary is this really? do aspects pose additional problems for tools? what are useful operations on PCD markers? different types of aspects (heterogeneous/homogenous) need different type of support? conditional PCDs cflow / cflowbelow / if context via arg, target and this PCDs how to work with multiple aspects and PCDs. how to simplify PCD after (successive) operations 22

Related Work • Virtual Source Files – Stellation [Chu-Carroll, et. al. ], Master. Scope

Related Work • Virtual Source Files – Stellation [Chu-Carroll, et. al. ], Master. Scope [Teitelman, Manister] • Non-textual program representation – ENVY/Smalltalk [OTI Inc. ], Intentional Programming [Simonyi] • Multi-Dimensional Separation of Concerns – Hyper/J [Tarr, et. al. ], Mixin Layers [Smaragdakis, Batory] • Development Environments – Together [borland. com/together], Rational [ibm. com/software/rational], PIROL [Herrmann, Mezini], Views for Tools in Integrated Environments [Garlan], Bugdel [Usui&Chiba] 23

The End Many open questions – how useful/necessary is this really? – do aspects

The End Many open questions – how useful/necessary is this really? – do aspects pose additional problems for tools? – what are useful operations on PCD markers? – different types of aspects (heterogeneous/homogenous) need different type of support? – conditional PCDs cflow / cflowbelow / if – context via arg, target and this PCDs – how to work with multiple aspects and PCDs. – how to simplify PCD after (successive) operations Intentional versus extensional semantics of PCDs? 24