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.

Slides:



Advertisements
Similar presentations
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Advertisements

ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development.
1 Shyness in Programming Karl Lieberherr Demeter Research Group Northeastern University Boston.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
1 Why do we need XAspects Structure-shyness –Can build DSL objects using constructors and use AspectJ to implement meaning of DSL objects. Is inconvenient.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb Mostly taken from Bedir Tekinerdogan’s.
October - December 2013CSC5021: The Problem With Aspects (J P Gibson)1 The Problem With Aspects (AOP) A style of programming that attempts to abstract.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Deriving AO Software Architectures using the AO-ADL Tool Suite Luis Fernández, Lidia Fuentes, Mónica Pinto, Juan A. Valenzuela Universidad de Málaga
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Fall 2012.
Developing Adaptive J2ME Applications Using AspectJ Ayla Débora and Paulo Borba {add, Centro de Informática - UFPE.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
Demeter Interfaces: AP without Surprises Prof. Karl Lieberherr and Therapon Skotiniotis, Jeffrey Palm.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
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.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Expression evaluation E : S | C. S = int. C = Op E E. Op : A | M. A = “+”. M = “*”.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Take-Home Final COM 3205 Fall Stamp Coupling Def: data structure is passed as parameter, but called method operates on only some of the` individual.
Aspect Oriented Programming Gülşah KARADUMAN.
Schema Set getDefinedTypeNames() Set getUndefinedTypeNames() void addDef(Set def) void addUndef(Set undef, Set def) SchemaItem void addDef(Set def) void.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
Design Rules for Increasing Modularity with CaesarJ Carlos Eduardo Pontual Advisor: Paulo Borba 17/06/2010.
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.
Master’s Thesis Defense: Aspectual Concepts John J. Sung.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
System Body Thing * * Definition Fig. UML1 def body Ident S D T B definitions things.
Adaptive Software Kevin Cella Graduate Seminar 02/04/2005.
© Siemens AG, CT SE 2 C O R P O R A T E T E C H N O L O G Y 1 Model-Driven Development for Pluggable Collaborations Iris Groher, Stephan Bleicher, Christa.
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?
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Translating Traversals to AspectJ. Outline Motivation Demeter Process for Traversals AspectJ Translation Process.
DJ: traversal-visitor-style programming in Java Josh Marshall/ Doug Orleans Want to add more on traversal through collections and Aspectual Components.
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
AOP/cross-cutting What is an aspect?. An aspect is a modular unit that cross-cuts other modular units. What means cross-cutting? Apply AOP to AOP. Tease.
R R R A Brief Introduction to Aspect-Oriented Programming.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Spring 2012.
Functions Part I (Syntax). What is a function? A function is a set of statements which is split off into a separate entity that can be used like a “new.
Why Should You Care About Aspect-Oriented Programming? Karl Lieberherr CCIS.
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.
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
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.
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Crosscutting Capabilities for Java and AspectJ through DJ
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Discussion with Gregor Kiczales at UBC
Demeter Aspects Who We Are Aspectual Collaborations
Inheritance Anomalies
Aspect-Oriented Design and Patterns
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Lecture 21: Crosscutting Aspect-Oriented Programming Background
Structuring Adaptive Applications using AspectJ and AOM
Better Separation of Crosscutting Concerns with Aspectual Components
AOSD and the Law of Demeter: Shyness in Programming
AspectAda Aspect-Oriented Programming for Ada95
Aspect Oriented Software Design
Adaptive Programming in JAsCo
Presentation transcript:

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 –a specification language for expressing sets of join points (JPS) –a means of specifying behavior involving join points (BJP) –encapsulated units combining JPS and BJP (CSB) –method of attachment of units to base program (AU) Nine examples: AspectJ, DemeterJ, DJ, ATC, AspectC, Aspectual Collaborations, D (COOL, RIDL), BETA, RG

Now we go to a higher level Concerns Methods: any artifact (oo method, function, statement) used to describe/implement some concern. Definition of relation R(Concern, Method): A method m is related to a concern C (abbreviated as R(C,m)), if m is used to describe/implement some concern.

Relation R Definition is intentionally left vague. We simply assume a relation between concerns and methods. For example, we could define: R(C,m) if m contains a join point relevant to concern C. But this assumes the definition of a join point model.

Measuring crosscutting of a concern cc(C) = |concerns(methods( C ))| - 1 methods(C) = {m | R(C,m)} concerns(m) = {C | R(C,m)} concerns(m’)=  m in m’ concerns( m ), m’ a set of methods cc(C) = |image(C in (R -1  R))| - 1 C: a concern m: a method

Crosscutting C1 C3 C2 m1 m2 m3 m4 m5 C4 cc(C2) = |concerns(methods( C2 ))| - 1 = |{C1,C2,C3,C4}| - 1 = 3 cc(C2) = |image(C2 in (R -1  R))| - 1 = 3 concerns methods bipartite graph

Concern-Oriented Analysis Graph (COA Graph) Doug: cross-cutting not something we want to tune but a quantity that exists in nature. That is what Gregor thinks: cross-cutting is a deep property of concerns. But also: Doug: there are good and bad analyses.

The Primary Concern of a Method PCofM We add more information to the COA graph: some of the edges of R are used to create a mapping from methods to concerns that partitions the methods into disjoint sets. PCofM(C,m) maps m to primary concern C A primary concern may be a class or a generic function, etc.

Scattering Two kinds of scattering: –method scattering: ms –primary concern scattering: pcs ms(C) = |image(C in R)| pcs(C) = |image(C in (PCofM  R))|

Measuring scattering and crosscutting of a concern pcs(C) = |image(C in (PCofM  R))| cc(C) = |image(C in (R -1  R))| - 1 f(C,T) = image(C in (T  R)) pcs(C) = f(C, PCofM) cc(C) = f(C, R -1 ) Note: |cc(C)| >= |pcs(C)| scattering and crosscutting have a lot in common: they are two different uses of same function.

Scattering C1 C3 C2 m1 m2 m3 m4 m5 C4 pcs(C) = |image(C in (PCofM  R))| = |{C1,C3}| = 2 concernsmethods primary

Scattering C1 C3 FC m1 m2 m3 m4 m5 Structure Concern pcs(FC) = |image(FC in (PCofM  R))| = |{C1,C3}| = 2 s(Structure Concern) = 2

Measuring crosscutting of a concern cc(C) = |concerns(methods( C ))| - 1 methods(C) = {m | R(C,m)} concerns(m) = {C | R(C,m)} concerns(m’)=  m in m’ concerns( m ), m’ a set of methods methods(C’)=  C in C’ methods( C ), C’ a set of concerns old

Crosscutting concerns A concern C1 crosscuts a concern C2 if C2 in concerns(methods( C1 )). A concern C1 crosscuts a concern C2 if C2 in image(C1 in (R -1  R)). Define the crosscutting graph of concerns as follows: there is an edge between two concerns C1, C2 iff C1 crosscuts C2. ??

Now focus on oo Primary concerns are classes.

Doug’s view: Good view The graph of concerns and methods needs to be turned into a program. –Some of the concerns are turned into classes adaptive methods polytypic functions (Patrik?) AspectJ aspects generic functions aspectual collaborations, personalities etc.

Class selection partition methods. Concerns that are not classes are aspects. once we have classes, we can measure scattering in an ad-hoc implementation of aspects. our goal is to avoid ad-hoc implementation and put information about aspects into a module.

Tangling in aspects But keeping information about an aspect in a module leads to tangling in the module. But that is better than the scattered ad-hoc implementation. We trade bad scattering and tangling for good tangling.

Question Working with aspects trades scattered code spread over several classes with modularized, but tangled code in the aspects. Why is this an improvement? Answer: –The modularized code is easier to understand. The tangling in the module cannot be avoided because we need to talk about hooks where the aspect will influence the behavior.

Question References to the hooks will be scattered throughout the module. Scattering inside one module is better than scattering across primary concerns. –Abstraction use abstract aspects or aspectual collaborations. Reuse them multiple times.

Java Program: used but not defined class System{ String id = “from Thing to edu.neu.ccs.demeter.Ident”; void repUndef(ClassGraph cg){ checkDefined(cg, getDefThings(cg));} HashSet getDefThings(ClassGraph cg){ String definedThings = "from System bypassing Body to Thing"; Visitor v = new Visitor(){ HashSet return_val = new HashSet(); void before(Thing v1){ return_val.add(cg.fetch(v1, id) );} public Object getReturnValue(){return return_val;}}; cg.traverse(this, definedThings, v); return (HashSet)v.getReturnValue(); } green: traversal black bold: structure purple: advice red: parameters repUndef is a modular unit of crosscutting implementation. Ad-hoc implementation may cut across 100 classes.

void checkDefined(ClassGraph cg, final HashSet classHash){ String usedThings = ”from System through Body to Thing"; cg.traverse(this, usedThings, new Visitor(){ void before(Thing v){ Ident vn = cg.fetch(v, vi); if (!classHash.contains(vn)){ System.out.println("The object "+ vn + " is undefined."); }}});} }

Doug’s observations Three kinds of aspects: –partition methods primary concerns, classes traversals, generic functions –not method partitioning aspects those aspects may crosscut each other where do adaptive methods fit in? in both?