32
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales

University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

University of British Columbia

Software Practices Lab

CAS Seminar 06

Fluid AJ - A Simple Fluid AOP

Tool

Terry HonGregor Kiczales

CAS Seminar 06 2

General AOP Terminology

• Crosscutting concerns– Concerns that do not correspond to the core

decomposition of the system

• Join point model– Join points– Means of identifying join points– Means of affecting join points

• Weaving

CAS Seminar 06 3

Crosscutting Concerns• Code becomes scattered and tangled

• Scattered code– Spread around the system

• Tangled code– Mixed with other concerns

• Hard to maintain and manage as system evolve

CAS Seminar 06 4

Linguistic AOP Approach

• Crosscutting concerns are captured in aspects

• Aspects are new constructs in the programming language

• Weaving is done at compile or post-compile time

CAS Seminar 06 5

Problem Statement

• Linguistic AOP approach has disadvantages– Requires new language adoption– Compile time weaving means developers cannot

reason about woven code

• Fluid AOP provides another option for programming in AOP

CAS Seminar 06 6

Fluid AOP

• Supports modularization of crosscutting concerns in IDE

• Provides temporary view that modularizes current concern

• These views (aspects) can be generated each time it is needed, or can be stored as a meta object

CAS Seminar 06 7

Fluid AJ

• Eclipse plugin

• Implements the principles of Fluid AOP

• Modularizes interaction with crosscutting code

• Edit time weaving

CAS Seminar 06 8

JPM for Fluid AJ

• Join points– Code fragments in java files

• Method• Field• Constructor

• Means of identifying join points– Pointcuts: method, field or constructor

signatures, type patterns

• Means of affecting join points– Editing of text

CAS Seminar 06 9

Display Updating• Consider a simple

drawing application (JHotDraw)

• Want to implement display updating (observer pattern)

CAS Seminar 06 10

- Use the following pointcut to describe join points

Display Updating cont’d

- Display updating calls need to be added at the end of these join points

pointcut change: execution(public void figures.Shape+.set*(*))

CAS Seminar 06 11

Display Updating Aspect

• So now we have an aspect that looks like the following (very similar syntax to AspectJ)

public aspect DisplayUpdating

pointcut change: execution(public void figures.Shape+.set*(*))

after returning: change { }

CAS Seminar 06 12

CAS Seminar 06 13

CAS Seminar 06 14

CAS Seminar 06 15

Matched join points are “prepared” by adding comments and advice block

CAS Seminar 06 16

Editing the advice body here

Keeps all these code blocks in synch – a crosscutting slice.

CAS Seminar 06 17

Intertype Declarations

• Want to add a Display field for each Shape class

• Instead of calling static update method, we will call the update on the Display object

• Add the following to the DisplayUpdating aspect

declare for figures.Shape{ private displays.Display display; }

CAS Seminar 06 18

CAS Seminar 06 19

CAS Seminar 06 20

Different Fluid AJ view

• Editing of crosscutting concern is modularized

• Viewing of the concern is still scattered and tangled with other concerns

• Another way developer can interact with code is to gather all the join points of a concern into one view

CAS Seminar 06 21

Gather declaration

• Use the pointcut change defined in the previous aspect

• Instead of using the pointcut in an advice, we can use it in a gather declaration

public aspect GatherDisplayUpdating {

pointcut change: execution(public void figures.Shape+.set*(*))

gather : change

}

CAS Seminar 06 22

CAS Seminar 06 23

CAS Seminar 06 24

CAS Seminar 06 25

Fluid AJ vs. AspectJ (Linguistic AOP)• Different join point model

– Dynamic vs. static

• Different adoption profile– Plain old Java tools can be used on all but

aspect (.fa) files– Aspect files are only meta files– Edit time weaving– Woven files are in normal java code

CAS Seminar 06 26

Status

• Implemented a simple prototype as an Eclipse plugin– 3 kinds of advice: before, after and after

returning– Execution pointcut– Intertype declarations– Very basic gather declarations

CAS Seminar 06 27

Open Questions

• What happens when a developer changes an advice body outside of the aspect file?

• What happens if an advice body is deleted?

• What is the best way to show a concern (modularizing both viewing and editing of concern)?

• Possible intermediate step in AOP adoption or AOP solution qua itself?

CAS Seminar 06 28

Another Design Space

• Advice declarations gave us modularization for editing of concerns

• Gather declarations gave us modularization for viewing of concerns

• The next step would be to provide a view that can both modularize the editing and also the viewing of crosscutting concerns

CAS Seminar 06 29

Overlay• Gathers all join points

in the concern and present an abstraction of them

• When you edit the abstraction, the join points also change

• Provides modularization for editing and viewing of concern

CAS Seminar 06 30

Related Work

• [Toonim et. al., 04]– Linked Editing– Persistent linking of crosscutting code snippets– No semantic approach for describing

crosscutting concerns– User has to manually select each join point

• [Miller et. al., 01]– Simultaneous Text Editing– Provides simple language for describing

crosscutting concerns– Non-persistent linking

CAS Seminar 06 31

Related Work cont’d

• [Harrison et. al., 02]– Concern Manipulation Environment (CME)– Post-compile time weaving– No mechanisms for reasoning about woven code

University of British Columbia

Software Practices Lab

CAS Seminar 06

Questions?

Fluid AOP – Fluid AJ Editor

Terry [email protected]