Master’s Thesis Defense: Aspectual Concepts John J. Sung.

Slides:



Advertisements
Similar presentations
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Advertisements

Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
1 Shyness in Programming Karl Lieberherr Demeter Research Group Northeastern University Boston.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Explaining DJ with AOP. DJ ClassGraph.traverse (this,whereToGo,whatToDo) Intertype declaration Advice.
Introduction To System Analysis and Design
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
1 Basic Object Oriented Concepts Overview l What is Object-Orientation about? l What is an Object? l What is a Class? l Constructing Objects from Classes.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Integration of Demeter and AspectJ (DAJ) John J. Sung.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
C++ fundamentals.
Introduction To System Analysis and design
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
Change Impact Analysis for AspectJ Programs Sai Zhang, Zhongxian Gu, Yu Lin and Jianjun Zhao Shanghai Jiao Tong University.
Integrating Independent Components with On-Demand Remodularization based on OOPSLA 2002 paper by Mira Mezini Klaus Ostermann Prepared by Karl Lieberherr.
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
Extensible Plug-ins for Aspect-Oriented Programming Macneil Shonle*Ankit Shah.
Introduction To System Analysis and Design
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
AspectWrapper CHALFOUN Pierre et BUIST Éric. Overview Introduction – what and why In a nutshell – main components Our approach – how we did it Demo –
John J. Sung TA Consulting. Motivation for TraversalJ KL Enterprises identified AOP Enter into the AOP market early Add value by adding traversals to.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
AOP Foundations Doug Orleans Karl Lieberherr. What we did earlier AOP languages have the following main elements: –a join point model (JPM) wrt base PL.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Adaptive Software Kevin Cella Graduate Seminar 02/04/2005.
1 Testing Object- Oriented Programs CS 4311 J. McGregor and D. Sykes. A Practical Guide to Testing Object-Oriented Software, Addison-Wesley, I. Burnstein.
1 Functional Visitor Ø Motivation Example Container checking -- Make sure each Container is not overloaded Weight Item + int total( ) w Container + int.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Course Progress Lecture 1 –Java data binding: Basket example: UML class diagram -> class dictionary without tokens-> language design -> class dictionary.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Checking LoD in AspectJ Show the idea, not the details. How can we precisely express it in a programming language?
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
Translating Traversals to AspectJ. Outline Motivation Demeter Process for Traversals AspectJ Translation Process.
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
3 Project Objectives Aspectual Collaborations (AC) for the Connection Aspect –Metric: Does the restructuring of the UAV code with AC reduce the tangling.
UBC software modularity group 1/14/02 UCSD1 Discussion with Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what.
COM1205 TraversalJ Project* Pengcheng Wu Feb.25,2003.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Aspect-Oriented Software Development (AOSD)
AO Mechanisms in Demeter1 Discussion with Gregor Kiczales at UBC Ontology of AOP Ontology is the study of what there is, an inventory of what exists. An.
Talk only to your friends that share the same concerns (Law of Demeter for Concerns) Midterm Review February 2004.
Aspect-oriented Code Generation Approaches Abid Mehmood & Dayang N. A. Jawawi Department of Software Engineering Faculty of Computer Science and Information.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Modern Programming Tools And Techniques-I
Crosscutting Capabilities for Java and AspectJ through DJ
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
About the Presentations
Discussion with Gregor Kiczales at UBC
For John.
Demeter Aspects Who We Are Aspectual Collaborations
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Better Separation of Crosscutting Concerns with Aspectual Components
LoD in AspectJ Karl Lieberherr.
AOSD and the Law of Demeter: Shyness in Programming
Options for Demeter intergration into AspectJ
Aspect Oriented Software Design
Presentation transcript:

Master’s Thesis Defense: Aspectual Concepts John J. Sung

AspectJ from PARC AJ J EMETERJ (Demeter AspectJ) Aspect-oriented tools referred to in this talk

Static Scattering and Tangling aspect i is scattered across many classes (i = 1,2,3) class X tangles aspects 1, 2 and 3 aspect1aspect2aspect3 class A consisting of three aspects classes for aspect1 classes for aspect2 classes for aspect3 Class X class diagram Adding to classes

Dynamic Scattering and Tangling program execution involving three aspects (colors r b g) program call tree (objects executing method calls) Each aspect (colors) is scattered across many classes (shapes) Class tangles all three aspects At those calls the aspect enhances the behavior classes this(s) target(t) f(..) Enhancing calls t.f(..);

subcomputation = join points related to traversing through the objects guided by traversal specification and class graph.

Pointcut –set of execution points of any method, … –rich set of primitive pointcuts: this, target, call, … + set operations –where to enhance Advice –how to enhance Visitor method sig. –set of execution points of traversals –specialized for traversals (nodes, edges) –where to enhance Visitor method bodies –how to enhance DJAspectJ From DJ to AspectJ

Outline Motivation JPM and Demeter Concepts Demeter integrated with AspectJ (DAJ) DAJ Semantics/Syntax DAJ System Architecture Four Graph Model of Programs (4GMP) Conclusion

Motivation Aspect Oriented Software Development Gaining Momentum –1 st International Conference on AOSD –AspectJ, DemeterJ, ConcernJ, HyperJ, etc. AOSD is Relatively Young –DemeterJ ~1989 –AspectJ ~1997 Karl J. Lieberherr: Demeter C DemeterJ 1996 Karl J. Lieberherr: Demeter C DemeterJ 1996

Questions What are the fundamental concepts behind AOSD? How are these concepts related? Can these concepts be mixed? What are the fundamental problems that software language features attempt to solve? Karl J. Lieberherr: How can these concepts be combined? Karl J. Lieberherr: How can these concepts be combined?

Joinpoint Model (JPM) Fundamental Concepts –Joinpoint, Pointcut, Advice, Aspect, Introduction –Concepts applied to call graph in AspectJ –Building or Construction Metaphor Karl J. Lieberherr: Also to class graph : introductions Karl J. Lieberherr: Also to class graph : introductions

Construction Metaphor Concepts in JPM create an image of constructed structures from building blocks Karl J. Lieberherr: Of structures constructed from building … Karl J. Lieberherr: Of structures constructed from building …

AspectJ Abstraction of Programs Call GraphPointcuts ++ Advices => Program

AspectJ Abstraction of Programs foo(){ x = 0; if (x < 0) throw KException; } bar int x; b1.foo(); c1 within(bar) aspect before() : within(bar) { }

Another View Java Program AspectJ Advice pointcut advice body join point

Demeter Fundamental Concepts –Class Graph, Strategy, Visitor, Advice –Concepts applied to data structures, i.e. class graph –Journey Metaphor

Journey Metaphor Concepts in Demeter create an image of a person on a journey

Demeter Abstraction of Programs Class Graph Strategy Graph ++ Visitor Advices => Program

Demeter Abstraction of Programs => before(..) after(..) before(..) Class Graph Strategy Graph Traversal Graph Visitor Advices

Mixing Concepts Application of JPM on Demeter –Class graph is built of classes and edges –Joinpoints become the points along traversals –Advices are executed at these joinpoints

Mixing Concepts Application of Demeter on JPM –CPU is the global visitor –Advice with a pointcut are Demeter advices for the global visitor –Visitor is traversing the Dynamic Call Graph Karl J. Lieberherr: Advices with a … Karl J. Lieberherr: Advices with a … Karl J. Lieberherr: This continues to be non-convincing. Karl J. Lieberherr: This continues to be non-convincing.

Demeter AspectJ (DAJ) Uses AspectJ as the backend compiler Uses DJ to generate Class Graph, Traversal Graph Generates the AspectJ implementation of the traversal Defines a traversal specification language Implemented using DemeterJ Application of JPM on Demeter

Traversal Specification Language Designed to have similar syntax to DJ and AspectJ Allows users to specify Class Graph, Traversal, and Visitor Generates AspectJ implementation of traversals

Class Graph Specification Default Class Graph –ClassGraph cgvar; Class Graph Slice –ClassGraph cgvar = new ClassGraph(cg, “strategy”);

Visitor Specification Uses Java Reflection to obtain method signatures Recognized methods are –around, before, after, start, finish, returnValue Visitor Declaration –Visitor visitorClass;

Traversal Specification Default Traversal Specification –declare traversal tvar : “strategy”; Traversal with Class Graph –declare traversal tvar(cgvar) : “strategy”; Traversal with Visitor –declare traversal tvar(cgvar, visitorvar) : “strategy”;

Aspect Specification aspect aspectName { class graph declarations; traversal declarations; visitor declarations; }

What DAJ Generates For each default and class graph slice traversal –method void tvar() for the source node of the traversal strategy For each traversal with visitor –method void tvar() for the source node of the traversal strategy –method void tvar(visitorClass) for the source node of the traversal strategy –Appropriate AspectJ Advices for each advice in visitorClass

A Simple Basket Example class Basket { Basket(Fruit _f, Pencil _p) { f = _f; p = _p; } Basket(Fruit _f, Fruit _f2, Pencil _p) { f = _f; f2 = _f2; p = _p; } Fruit f, f2; Pencil p; } class Fruit { Fruit(Weight _w) { w = _w; } Weight w; } class Orange extends Fruit { Orange(Color _c) { super(null); c=_c;} Orange(Color _c, Weight _w) { super(_w); c = _c;} Color c; } class Pencil {} class Color { Color(String _s) { s = _s;} String s; } class Weight{ Weight(int _i) { i = _i;} int i; int get_i() { return i; } }

A Simple Basket Example Basket FruitPencil p f, f2 Orange Weight Color wc String s int i

BasketVisitor class BasketVisitor { int total; public void start() { total = 0; } public int returnValue() { return total; } void before(Weight w) { total += w.get_i(); }

Basket Traversal aspect BasketTraversal { ClassGraph default; ClassGraph myClassGraph = new ClassGraph(default, "from Basket to *"); Visitor BasketVisitor; declare traversal t1(myClassGraph,BasketVisitor) : "from Basket to Weight"; declare traversal t2(myClassGraph,BasketVisitor) : "from Basket via Orange to Weight"; }

Basket Main class BasketMain { static public void main(String args[]) throws Exception { Basket b = new Basket(new Orange(new Color("orange"), new Weight(5)), new Fruit( new Weight(10)), new Pencil() ); BasketVisitor bv = new BasketVisitor(); b.t1(bv); int totalWeight = bv.returnValue(); System.out.println("Total weight of basket = " + totalWeight); b.t2(bv); totalWeight = bv.returnValue(); System.out.println("Total weight2 of basket = " + totalWeight); } Karl J. Lieberherr: Visitor object generation not automatic. More flexibility this way. Karl J. Lieberherr: Visitor object generation not automatic. More flexibility this way.

Generated Code for Visitor public aspect BasketTraversal { static BasketVisitor t1_visitor; public void Basket.t1(BasketVisitor v) { t1_visitor=v; t1_visitor.start(); t1(); } before(Weight host) : call(public void t1*()) && target(host) { t1_visitor.before(host); } void Basket.t1() { t1_copy0(); } Karl J. Lieberherr: What is this? Karl J. Lieberherr: What is this?

Basket Class Graph Basket FruitPencil p f, f2 Orange Weight Color wc String s int i

Generated Code for Traversal // traversal t1 : {source: Basket -> target: Weight} with { } public void Basket.t1_copy0(){ if (f != null) t1_copy0_crossing_f(); if (f2 != null) t1_copy0_crossing_f2(); } public void Basket.t1_copy0_crossing_f() { f.t1_copy0();} public void Basket.t1_copy0_crossing_f2() { f2.t1_copy0();} public void Fruit.t1_copy0(){ if (w != null) t1_copy0_crossing_w(); } public void Fruit.t1_copy0_crossing_w() { w.t1_copy0();} public void Weight.t1_copy0(){ } public void Orange.t1_copy0(){ super.t1_copy0(); } pointcut pointcut_t1() : call(public void t1*()); before () : pointcut_t1 () { System.out.println(thisJoinPoint); }

System Architecture DAJ Main –Parses command line arguments –Manages the DAJ code generation phases Stub Generation –Generates stubs for traversal methods Traversal Generation Compilation –Compiles using ajc the stubs, user code, and CreateClassGraph.java Karl J. Lieberherr: How are stubs different from traversals? Karl J. Lieberherr: How are stubs different from traversals?

System Architecture Traversal Generation –Uses DJ, Java Reflection, and DemeterJ to generate AspectJ traversal code Traversal Compilation –Compiles the generated traversal code with user code

System Architecture Stub Generation Traversal Generation Compilation Traversal Generation Traversal Compilation DAJ Main method call shell Karl J. Lieberherr: Do not mention shell scripts Karl J. Lieberherr: Do not mention shell scripts

DAJ Process Stub Generation Traversal Files Generated Stubs Traversal Generation Compilation Class Files Traversal Generation Traversal Compilation User Code CreateClassGraph.java Traversal Implementation Karl J. Lieberherr: CreateClassGraph.java is provided by DAJ Very confusing naming What information is generated by each box: input files and output files and who provides them Karl J. Lieberherr: CreateClassGraph.java is provided by DAJ Very confusing naming What information is generated by each box: input files and output files and who provides them

Future Improvements Two syntax supported –DJ/Java like style –AspectJ’s declare syntax Handle Collections –Traversal through Java Collections Handle interfaces –Traversal “correctly” for interfaces Karl J. Lieberherr: Correctly?? Karl J. Lieberherr: Correctly??

Four Graph Model of Programs Merging of graphs in Demeter and JPM Model for creating relationships between different features AOP feature analysis Only a proposal and needs lots of work

4GMP Compile-TimeRuntime Data Structures Algorithm Program Class Graph Object Graph Static Call Graph Dynamic Call Graph Executable Process

Compile-Time vs. Run-Time Compile-time graphs specify all possible run-time graphs The computer system combines the compile-time graph with input to generate the run-time graph In a way, the compile-time graph has factored out the commonalities within the run-time graph Factorizational Concern

Input Specification Processor Output

Factorizational Concern +

Factorizational Concern Examples Functions that are used multiple times Inherited methods and data members Parser generation for DemeterJ Wildcards for pointcut designators in AspectJ Traversal generation in DAJ

Data Structure vs. Algorithm One of many ways of slicing up a program –data flow / control flow –Layering –Modules It does not change the amount of code that one has to write Large programs are a fact of life and it needs to be organized in some way Organizational Concern

Organizational Concern Examples Functions that are called only once Non-inherited methods and data members Open classes in DemeterJ Introductions in AspectJ

Factorizational/Organizational Concerns Most programming language features have both characteristics depending on their uses Both are needed to cope with the problem of programs growing ever larger

Concern Relationship Diagram We may approximate relationships between features and the graphs in 4GMP

Concern Relationship Diagram Class Graph Object Graph Static Call Graph Dynamic Call Graph FC OC Concern Relationship FC = Factorizational Concern OC = Organizational Concern

AspectJ CRD Class Graph Object Graph Static Call Graph Dynamic Call Graph FC OC FC = Factorizational Concern OC = Organizational Concern Introduction Pointcut Join Point Aspect Advice SP = Specification Feature SP FC OC SP FC

DemeterJ CRD Class Graph Object Graph Static Call Graph Dynamic Call Graph FC OC FC = Factorizational Concern OC = Organizational Concern FC Strategy Graph Class Dictionary Traversal Graph Visitor Advice OC FC OC FC

Ideal CRD Feature FC Feature FC Feature OC Feature OC

Ideal CRD Feature FC Feature FC Feature OC

What Good Are CRDs? CRD is a higher level feature map Allows designers to see imbalance of concerns Designers can fix these imbalances with appropriate features that address appropriate concerns Programming Feature Analysis!

DemeterJ Feature Analysis CRD has many FC relations Possibly add features with OC relations to Class Dictionary, Strategy Graph, Traversal Graph

DemeterJ CRD Class Graph Object Graph Static Call Graph Dynamic Call Graph FC OC FC = Factorizational Concern OC = Organizational Concern FC Strategy Graph Class Dictionary Traversal Graph Visitor Advice OC FC OC FC OC

AspectJ Feature Analysis CRD has many OC relations Possibly add features with FC relations to Aspect and Introductions

AspectJ CRD Class Graph Object Graph Static Call Graph Dynamic Call Graph FC OC FC = Factorizational Concern OC = Organizational Concern Introduction Pointcut Join Point Aspect Advice SP = Specification Feature SP FC OC SP FC

Problems With CRDs In what scope should one create CRDs? –Should AspectJ and DemeterJ CRDs account for features in Java? Most features have FC and OC –How do I deal with these features?

Other Types of Concerns Interface Concerns –When two entities within a program need to communicate –Abstract classes in OOP –Interfaces in Java Specification Concerns –Things that programmers want to specify or reference –Java reflections –AspectJ joinpoints

Questions What are the fundamental concepts behind AOSD in Demeter and AspectJ? How are these concepts related? Can these concepts be mixed? What are the fundamental problems that software language features attempt to solve?

Conclusions Metaphors used in Demeter and JPM –Construction and Journey Metaphors –Usage of one or the other depends on the users and application –Can describe each other –Mixable

Conclusions DAJ –Mixing Demeter with AspectJ concepts –Uses DJ, DemeterJ and AspectJ –

Conclusions Four Graph Model of Programs –Merges graphs in Demeter and AspectJ –Factorizational/Organizational Concerns –Concern Relationship Diagram –Programming Feature Analysis –Needs lots of work!

Future Direction Try mixing other tools –ComposeJ, HyperJ, etc. Feature analysis of other tools and concepts Investigate other types of concerns Relationship between concerns relationships in features with HCI and SE

References