1 Deriving Refactorings for AspectJ Leonardo Cole Paulo Borba Informatics Center Federal University of Pernambuco Brazil.

Slides:



Advertisements
Similar presentations
Rodrigo Bonifácio Paulo Borba Informatics Center Federal University of Pernambuco Brazil Sérgio Soares Department of Computing.
Advertisements

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
1 Basic Laws of Object Modeling Rohit Gheyi Tiago Massoni Paulo Borba Software Productivity Group Informatics Center – UFPE.
A Brief Introduction to Aspect-Oriented Programming Zhenxiao Yang.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
Classes. Object-Oriented Design Method for designing computer programs Consider “objects” interacting in the program –Example: a zoo, a gradebook.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
More on AspectJ. aspect MoveTracking { private static boolean _flag = false; public static boolean testAndClear() { boolean result = _flag; _flag = false;
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Fall 2012.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
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.
1 Metamodel Access Protocols for Extensible Aspect-Oriented Modeling Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Shinji Sano(Kyushu Institute.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton February 28th, 2003 Advisor: David G. Hannay Client:
POSL (Principles of Software Languages) Gr. Kyushu Institute of Technology, Japan Pointcut-based Architectural Interface.
Aspect Oriented Programming Gülşah KARADUMAN.
Generative Programming. Automated Assembly Lines.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
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.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
1 Proving aspect-oriented programming laws Leonardo Cole Paulo Borba Alexandre Mota Informatics Center Federal University of.
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.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Aspect-Oriented Action Semantics Descriptions Luis Menezes University of Pernambuco
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
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.
Aspect Oriented Development Alex Beatty.  Purpose  Cross-cutting Concerns  Join Points, Pointcuts, and Advices  Weaving  Invasive vs. Non-Invasive.
Alloy-based Lightweight Verification for Aspect-oriented Architecture Naoyasu Ubayashi(Kyushu Institute of Technology) Yuki Sato(Kyushu Institute of Technology)
AOP-Driven Variability in Software Product Lines Vander Alves, Ayla Dantas, and Paulo Borba Informatics Center – UFPE – Brazil
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
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
Applying Aspect-Orientation in Designing Security Systems Shu Gao Florida International University Center for Advanced Distributed Systems Engineering.
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.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Aspect-Oriented Software Development (AOSD)
1 An AOP Implementation Framework for Extending Join Point Models Naoyasu Ubayashi(Kyushu Institute of Technology, Japan) Hidehiko Masuhara(University.
Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS.
Aspect-Oriented Generation of the API Documentation for AspectJ
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Aspect-Oriented Programming
Aspect-Oriented Design and Patterns
Aspect Oriented Programming
Structuring Adaptive Applications using AspectJ and AOM
AspectAda Aspect-Oriented Programming for Ada95
Presentation transcript:

1 Deriving Refactorings for AspectJ Leonardo Cole Paulo Borba Informatics Center Federal University of Pernambuco Brazil

2 Problem Aspect-oriented developers are identifying common transformations for aspect-oriented programs Refactorings are generally complex and global It is difficult to verify if a defined refactoring preserves behaviour

3 Our Approach Primitive laws of programming simple, localized, intuitive and easier to understand Two transformations Bi-directional Guarded by pre-conditions We use the laws to - Derive complex and global refactorings - Verify that an existing refactoring preserves behaviour

4 Deriving Refactorings Composing Laws Refactoring

5 Outline Aspect-oriented programming laws Evaluation Conclusions

6 Aspect-Oriented Programming Laws Simple and localized Two transformations Bi-directional One direction may not increase code quality Our laws define equivalences between two programs given that the preconditions are respected

7 Make Aspect Privileged ts privileged aspect A { pcs as } = (  ) Advice bodies from as do not refer to private members declared in ts. ts aspect A { pcs as }

8 Add before-execution ts class C { fs ms T m(ps) { body’; body } ts class C { fs ms T m(ps) { body } = paspect A { pcs before(context) : exec(C.m) && bind(context) { body’ } as } paspect A { pcs as } (  ) body’ does not declare or use local variables; body’ does not call super ; …

9 Example public class Account { private double balance;... public void debit(double amount) { Access.check(new Permission(…)); //debit logic }... } privileged aspect PermissionAspect { } Source: Laddad, 2003 Aspect Oriented Refactoring Series

10 Applying Add Before-Execution Law public class Account { private double balance;... public void debit(double amount) { //debit logic }... } privileged aspect PermissionAspect { before(Account cthis, double amount): execution(void Account.debit(double) && this(cthis) && args(amount) { Access.check(new Permission(…)); }

11 Summary of laws LawNameLawName 1Add empty aspect16Remove argument parameter 2Make aspect privileged17Add catch for softened exception 3Add before-execution18Soften exception 4Add before-call19Remove exception from throws clause 5Add after-execution20Remove exception handling 6Add after-call21Move exception handling to aspect 7Add after returning-execution22Move field to aspect 8Add after returning-call23Move method to aspect 9Add after throwing-execution24Move implements declaration to aspect 10Add after throwing-call25Move extends declaration to aspect 11Add around-execution26Extract named pointcut 12Add around-call27Use named pointcut 13Merge advices28Move field introduction up to interface 14Remove this parameter29Move method introduction up to interface 15Remove target parameter30Remove method implementation

12 Evaluation We derived existing aspect-oriented refactorings from the laws We restructured two object-oriented applications modularizing crosscutting concerns with aspects

13 Refactorings: Extract Pointcut ts aspect A { pointcut p(ps) : exp … before(ps) : p (  ps) { body } … after(ps) : p (  ps) { body’ } … } = ts aspect A { … before(ps) : exp { body } … after(ps) : exp { body’ } … }

14 Extract Pointcut Preconditions Summary Law 12 – Extract named pointcut Law 32 – Use named poitncut (  ) There is no pointcut named p in pcs ; (  ) There is no reference to p in ts and A. Law 12Law 32

15 Extract Method Calls Summary Law 2 – Add before-execution Law 9 – Merge advices Law 27 – Remove this parameter Law 28 – Remove argument parameter Law 2Law 9 Law 27 Law 28 Extract Pointcut

16 Other Refactorings Extract Interface Implementation Extract Exception Handling Extract Concurrency Control Evolving Product Lines …

17 Refactoring to AspectJ General OO Refactorings + AO Derived Refactorings + Laws Before: OO After: AO

18 Applications Two commercial applications First Mobile Server Concurrency control Second HealthWatcher Distribution Problem with Extract Exception Handling

19 Conclusions AOP laws useful for deriving aspect- oriented refactorings Derivation of existing refactorings Some not derived Refactored applications Also useful to Education Transformation tools Provide deeper understanding of the language

20 Conclusions Hipotesys No packages, this is mandatory, … No abstract aspects, concurrency and reflection, … Soundness

21 Deriving Refactorings for AspectJ Leonardo Cole Paulo Borba Informatics Center Federal University of Pernambuco Brazil

22 Remove this Parameter (  ) t is not referenced from body. = ts paspect A { … before(ps) : this(T) && … { body } … } ts paspect A { … before(T t, ps) : this(t) && … { body } … }

23 Merge Advices (  ) The set of join points captured by exp1 and exp2 are disjoint. … = ts paspect A {... before(ps) : exp1 || exp2 { body }... } ts paspect A {... before(ps): exp1 { body } before(ps): exp2 { body }... }

24 Move field to aspect (  ) The field field of class C does not appear in ts and ms. = ts class C { fs ms } paspect A { T C.field... } ts class C { fs; T field ms } paspect A {... }

25 Add before-execution ts class C { fs ms T m(ps) { body’; body } ts class C { fs ms T m(ps) { body } = paspect A { pcs bars before(context) : exec(C.m) && bind(context) { body’ } afs } paspect A { pcs bars afs }

26 Extract Method Calls Example public class Account { private double balance;... public void debit(double amount) { Access.check(new Permission(…)); //debit logic } public void credit(double amount) {…}... } public aspect PermissionAspect { }

27 Applying Add Before-Execution public class Account { private double balance;... public void debit(double amount) { //debit logic } public void credit(double amount) {…}... } public aspect PermissionAspect { before(…): execution(void Account.debit(double) && … { Access.check(new Permission(…)); } before(…): execution(void Account.credit(double) && … { Access.check(new Permission(…)); }

28 Another Example public class Bank { private Transaction transaction;... public void remove(Account account) { transaction.begin(…); try { // remove account logic transaction.end(…) } catch (…) { transaction.rollBack(…); }... }

29 Applying laws Add before-execution Add after-execution returning Add after-execution throwing public class Bank { private Transaction transaction;... public void remove(Account account) { // remove account logic }... } aspect TransactionAspect {…}