320 likes | 419 Views
Fluid AJ - A Simple Fluid AOP Tool. Terry Hon Gregor Kiczales. 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.
E N D
Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales CAS Seminar 06
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
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
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
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
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
Fluid AJ • Eclipse plugin • Implements the principles of Fluid AOP • Modularizes interaction with crosscutting code • Edit time weaving CAS Seminar 06
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
Display Updating • Consider a simple drawing application (JHotDraw) • Want to implement display updating (observer pattern) CAS Seminar 06
Display Updating cont’d • Use the following pointcut to describe join points pointcut change: execution(public void figures.Shape+.set*(*)) • Display updating calls need to be added at the end of these join points CAS Seminar 06
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
Matched join points are “prepared” by adding comments and advice block CAS Seminar 06
Editing the advice body here Keeps all these code blocks in synch – a crosscutting slice. CAS Seminar 06
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
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
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
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
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
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
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
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
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
Related Work cont’d • [Harrison et. al., 02] • Concern Manipulation Environment (CME) • Post-compile time weaving • No mechanisms for reasoning about woven code CAS Seminar 06
Questions? Fluid AOP – Fluid AJ Editor Terry Hontyehon@cs.ubc.ca CAS Seminar 06