Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev.

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

1 An Aspect-Aware Outline Viewer Michihiro Horie and Shigeru Chiba Tokyo Institute of Technology, Japan.
Java.sun.com/javaone/sf | 2004 JavaOne SM Conference | Session BUS JavaOne 2004 What is AOP? Gregor Kiczales AspectMentor.com and University of.
Aspect-Oriented Programming Gregor Kiczales University of British Columbia © Copyright 2004, Gregor Kiczales. All rights reserved.
359C 10/1/05 Eric Wohlstadter Introductions –Name –Degree objective/Year –Research Area (or interests) Syllabus Aspect-Oriented Programming –AspectJ –AspectC.
1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb Mostly taken from Bedir Tekinerdogan’s.
CSE 2501 Review Declaring a variable allocates space for the type of datum it is to store int x; // allocates space for an int int *px; // allocates space.
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Aspect-oriented programming Laura Ricci A.A
Aspect-Oriented Software Development (AOSD) Tutorial #2 AspectJ Basics.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 8: Classes and Objects.
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.1 AO Tools: State of the (AspectJ™) Art and Open Problems Mik Kersten.
Software modularity group Gregor Kiczales Professor and NSERC/Xerox/Sierra Systems Software Design Chair University of British Columbia Principal Scientist.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Session 15 Modeling Traceability of Concerns in Architectural Views Mark Stobbe October 29,
1 More on Classes Overview l Overloading l The this keyword l The toString method l The equals method.
Aspect-Oriented Programming with AspectJ™ AspectJ.org Xerox PARC Erik Hilsdale Gregor Kiczales with Bill Griswold, Jim Hugunin, Wes Isberg, Mik Kersten.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Fall 2012.
An Introduction to AOP Original slides developed by Julie Waterhouse and Mik Kersten for OOPSLA 2004 AspectJ Tutorial ( kerstens.org/mik/publications/aspectj-
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
Object Oriented Programming Concepts OOP – reasoning about a program as a set of objects rather than as a set of actions Object – a programming entity.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Constructors and Encapsulation reading: self-checks: #10-17.
1 An Aspect-oriented Weaving Mechanism Based on Component-and-Connector Architecture Naoyasu Ubayashi (Kyushu Institute of Technology) February 12, 2008.
Aspect Oriented Programming Gülşah KARADUMAN.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, this reading: self-checks: #13-17 exercises:
Kiczales and Mezini - FOAL AOP and Modular Reasoning [ICSE05] Start with first-principles definition of modularity and modular reasoning –localization,
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors, Encapsulation, this reading:
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.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
Devon M. Simmonds Computer Science Department, CSC592 1 Devon M. Simmonds Computer Science Department University of North Carolina, Wilmington
1 Modularization of crosscutting concerns Write this public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0;
1 Contract-based Verification for Aspect-oriented Refactoring Naoyasu Ubayashi(Kyushu Institute of Technology) Jinji Piao(Kyushu Institute of Technology)
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
Applying Translucid Contracts for Modular Reasoning about Aspect and Object Oriented Events Mehdi Bagherzadeh Gary T. Leavens Robert Dyer Foundations of.
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
CS100A, Fall 1998 Key Concepts 1 These notes contain short definitions of the basic entities that make up a Java program, along with a description of the.
AOP and observer pattern. Design pattern General reusable solution to a commonly occurring problem in software design Not a finished design that can be.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
Kestrel Policy Enforcement and Refinement Douglas R. Smith Kestrel Institute Palo Alto, California.
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.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
AspectScope: An Outline Viewer for AspectJ Programs Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
AspectJ Development Tools Mik Kersten University of British Columbia October 28, 2003.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Constructors; Encapsulation reading: self-checks: #13-18,
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors, Encapsulation, this reading:
An Interface Mechanism for Encapsulating Weaving in Class-based AOP
Object initialization: constructors
Topic 28 classes and objects, part 2
Building Java Programs
Building Java Programs
Aspect-oriented programming
CSE 142 Lecture Notes Defining New Types of Objects
Building Java Programs
An Extensible Contract Verifier for AspectJ
Handout-4b More on Classes
Building Java Programs
Dr. R Z Khan Handout-3 Classes
Presentation transcript:

Aspect-Oriented Programming and Modular Reasoning G. KiczalesM. Mezini Presented by Alex Berendeyev

2 Overview  Goals  Example  Aspect-aware Interfaces and Their Properties  Modular Reasoning in AOP  Reasoning about Change  Open Issues

3 Goals To identify the key properties of aspect-aware interfaces and their effect on modularity Show that full power of AOP is compatible with modular reasoning

4 Example: Java interface Shape { public moveBy(int dx, int dy); } class Point implements Shape { int x, y; //intentionally package public public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; Display.update(); } public void setY(int y) { this.y = y; Display.update(); } public void moveBy(int dx, int dy) { x += dx; y += dy; Display.udpate(); } } class Line implements Shape { private Point p1, p2; public Point getP1() { return p1; } public Point getP2() { return p2; } public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; Display.update (); }

5 Example: AspectJ interface Shape { public moveBy(int dx, int dy); } class Point implements Shape { int x, y; //intentionally package public public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } class Line implements Shape { private Point p1, p2; public Point getP1() { return p1; } public Point getP2() { return p2; } public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; } aspect UpdateSignaling { pointcut change(): execution(void Point.setX(int)) || execution(void Point.setY(int)) || execution(void Shape+.moveBy(int, int)); after() returning: change() { Display.update(); }

6 Definition of Aspect-aware Interfaces Aspect-aware interfaces are conventional interfaces augmented with information about the pointcuts and advice that apply to a module.

7 Example: Aspect-aware Interfaces Shape void moveBy(int, int) : UpdateSignaling – after UpdateSignaling.move(); Point implements Shape int x; int y; int getX(); int getY(); void setX(int) : UpdateSignaling – after returning UpdateSignaling.move(); void setY(int) : UpdateSignaling – after returning UpdateSignaling.move(); void moveBy(int, int) : UpdateSignaling – after returning UpdateSignaling.move(); Line implements Shape void moveBy(int, int) : UpdateSignaling – after returning UpdateSignaling.move(); UpdateSignaling after returning: UpdateSignaling.move(): Point.setX(int), Point.setY(int), Point.moveBy(int, int), Line.moveBy(int, int);

8 Properties of Aspect-aware Interfaces  Interfaces depend on deployment Aspects contribute to interface of classes Classes contribute to interface of aspects  Therefore, A complete system configuration is necessary to define interfaces A system may have different interfaces

9 Statements  Modules remain the same  Composition leads to new crosscutting interfaces  Modular Reasoning requires a global analysis of deployment configuration

10 Formulation of Aspect-Aware Interfaces(1)  Intensional descriptions Line implements Shape void moveBy(int, int) : UpdateSignaling – after returning UpdateSignaling.move();

11 Formulation of Aspect-Aware Interfaces(2)  Extensional descriptions UpdateSignaling after returning: UpdateSignaling.move(): Point.setX(int), Point.setY(int), Point.moveBy(int, int), Line.moveBy(int, int);

12 Formulation of Aspect-Aware Interfaces(3)  Point abstraction or reduction UpdateSignaling after returning: UpdateSignaling.move(): Point.setX(int), Point.setY(int), Point.moveBy(int, int), Line.moveBy(int, int);  Including advice kind Line implements Shape void moveBy(int, int) : UpdateSignaling – after returning UpdateSignaling.move();

13 Modular Reasoning: Criteria  Localized implementation Code is textually local  Descriptive well-defined interface Describes how a module interacts with the rest of the system  Abstraction abstracts implementation  Interface enforcement Type checking (e.g. by a compiler)  Composability Modules can be composed automatically (e.g. by a class loader)

14 Modularity Analysis: Non-AOP  Localized implementation Textually local, but the boundary also includes display update  Descriptive well-defined interface Interfaces are clearly defined, but they fail to say anything about the included display update behavior  Abstraction The internal details of the classes could change without changing the interface. The coordinates of a Point could be stored differently for example  Interface enforcement The interfaces are enforced in that the Java type checker, loader and virtual machine ensure type safety  Composability The Java loader can load these with other classes in different configurations

15 Example: Java interface Shape { public moveBy(int dx, int dy); } class Point implements Shape { int x, y; //intentionally package public public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; Display.update(); } public void setY(int y) { this.y = y; Display.update(); } public void moveBy(int dx, int dy) { x += dx; y += dy; Display.udpate(); } } class Line implements Shape { private Point p1, p2; public Point getP1() { return p1; } public Point getP2() { return p2; } public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; Display.update(); }

16 Modularity Analysis: AOP  Localized implementation Locality is improved over the non-AOP implementation because the update signaling behavior is not tangled into the Point and Line classes  Descriptive well-defined interface The interfaces are now a more accurate reflection of their behavior – update signaling is reflected in the interfaces as arising from the interaction between the aspects and the classes

17 Example: AspectJ interface Shape { public moveBy(int dx, int dy); } class Point implements Shape { int x, y; //intentionally package public public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } public void moveBy(int dx, int dy) { x += dx; y += dy; } } class Line implements Shape { private Point p1, p2; public Point getP1() { return p1; } public Point getP2() { return p2; } public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; } aspect UpdateSignaling { pointcut change(): execution(void Point.setX(int)) || execution(void Point.setY(int)) || execution(void Shape+.moveBy(int, int)); after() returning: change() { Display.update(); }

18 Modularity Analysis: AOP (2)  Abstraction There is room for material variation in how each is implemented. For example, a helper method could be called to do the signaling, or the signaling could be logged  Interface enforcement Type checking works in the usual way, and in addition the advice is called when it should be and at no other times.  Composability It is possible to automatically produce a configuration that includes the shape classes but not the UpdateSignaling aspect.

19 Modularity Analysis: Comparison

20 Definitions  Modular reasoning means being able to make decisions about a module while looking only at its implementation, its interface and the interfaces of modules referenced in its implementation or interface  Expanded modular reasoning means also consulting the implementations of referenced modules  Global reasoning means having to examine all the modules in the system or sub-system

21 Reasoning about Change: Non-AOP  int x, y; //intentionally package public  private int x, y; Step 1: Global Reasoning public void moveBy(int dx, int dy) { p1.x += dx; p1.y += dy; p2.x += dx; p2.y += dy; Display.update(); } TO public void moveBy(int dx, int dy) { p1.setX(p1.getX() + dx); p1.setY(p1.getY() + dy); p2.setX(p2.getX() + dx); p2.setY(p2.getY() + dy); Display.update(); //double update }

22 Reasoning about Change: Non-AOP(2) Step 2: Reasoning about the change  A description of the invariant Implementation of the Display class or it’s documentation  expanded modular reasoning  Structure of update signaling global reasoning – to find all calls to update and discover the complete structure of display update signaling OR expanded modular reasoning – to just find the calls from setX and setY

23 Reasoning about Change: AOP  int x, y; //intentionally package public  private int x, y; Step 1: Global Reasoning public void moveBy(int dx, int dy) { p1.setX(p1.getX() + dx); p1.setY(p1.getY() + dy); p2.setX(p2.getX() + dx); p2.setY(p2.getY() + dy); } after() returning: change() && !cflowbelow(change()) { Display.update(); }

24 Reasoning about Change: AOP(2) Step 2: Reasoning about the change  A description of the invariant Documented in UpdateSignaling  one-step expanded modular reasoning Documented in Display  two-step expanded modular reasoning  Structure of update signaling The interface of UpdateSignaling is enough  modular reasoning

25 Reasoning about Change: Comparison  global reasoning is required to find all the references to the x and y fields.  documenting and allowing the programmer to discover the invariant  discovering the structure of update signaling Non-AOPAOP one-step expanded modular reasoning one (two)-step expanded modular reasoning global reasoning OR expanded modular reasoning modular reasoning

26 Open Issues  expand our concept of aspect-aware interfaces and the analysis here to full AspectJ (call, get and set join points)  higher-order value typing like generic types, state typing, behavioral specification  increase the expressive power and abstraction of pointcuts  Support for use of annotations