AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.

Slides:



Advertisements
Similar presentations
A Brief Introduction to Aspect-Oriented Programming Zhenxiao Yang.
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 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development.
Aspect Oriented Programming - AspectJ Radhika Rajput.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
20-May-15 Aspect-Oriented Programming Dave Matuszek University of Pennsylvania.
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.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
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.
Aspect Oriented Programming Written by Michael Beder.
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.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Introduction to AOP.
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.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Modularizing Web Services Management with AOP María Agustina Cibrán, Bart Verheecke { Maria.Cibran, System and Software Engineering.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
AOSD1 Aspect-Oriented Software Design Karl Lieberherr Theo Skotiniotis.
TRANSPARENT EXTENSION OF SINGLE- USER APPLICATIONS TO MULTI-USER REAL-TIME COLLABORATIVE SYSTEMS An Aspect Oriented Approach to Framework Integration ICEIS.
Aspect Oriented Programming An Introduction based on se-radio.net episode th October 2009 Aspect Oriented Programming - Nils Schmidt.
Introduction Better Faster Cheaper (pick any two) On-going issue that continues to motivate research in software engineering Applications: –continue to.
Aspect-Oriented Programming An Introductory Presentation Mike Landi MSCS Candidate Union University.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
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.
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)
1 Deriving Refactorings for AspectJ Leonardo Cole Paulo Borba Informatics Center Federal University of Pernambuco Brazil.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
问题 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
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.
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.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
Features of AOP languages AOP languages have the following main elements: –a join point model (JPM) wrt base PL –a specification language for expressing.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
Software Engineering Lecture 7
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Discussion with Gregor Kiczales at UBC
Aspect-Oriented Programming
Aspect-Oriented Design and Patterns
Implementation of the INFOD System using AOP
A Brief Introduction to Aspect-Oriented Programming
JAsCo an Aspect-Oriented approach tailored for
Structuring Adaptive Applications using AspectJ and AOM
AspectAda Aspect-Oriented Programming for Ada95
Aspect Oriented Software Design
Aspect Oriented Programming
Refactoring the Aspectizable Interfaces: An Empirical Assessment
Presentation transcript:

AOP-1 Aspect Oriented Programming

AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-3 Software Development Various methodologies have evolved Object-Oriented Paradigm is the most popular and practical in effect currently System composed of objects/ entities Used in all kinds of application development

AOP-4 Reasons to use OO Helps us manage complexity If done well, easier to make change Component based approach to developing systems But, what are the limitations of OO?

AOP-5 Limitations of OO OO advocates decomposing a system into entities As complexity increases, the limitations surface Breaking system into objects helps manage complexity However, can all the system concerns be decomposed into an object? –Not really –Move commonality into a base class? –How about spreading them across several objects? –Makes it harder to keep up with the change

AOP-6 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-7 Separation of Concerns We have heard this in OOP We want to separate the concerns in our system into manageable pieces OO does this to a certain extent But what about concerns at global level Concerns like security, transaction, tracing, logging, error handling, etc.

AOP-8 Crosscutting Concerns Some concerns are fairly localized within entities Other concerns cut across multiple elements in the system How about keeping these cross cutting concerns separately and weaving them horizontally into the system?

AOP-9 Weaving the system Tactical Concerns Crosscutting Global Concerns GlobalConcerns

AOP-10 Advantages Could we not write these as functions & call? –Results in code permeating though the system at various places – hard to maintain –Harder to express concerns this way –intrusive – you modify your code to invoke these concerns requires understanding at each level In this approach –You can focus on the concerns at one place –Easier to add and remove concerns –Easier to modify or fine tune concerns –Easier to understand –Efficient to implement –More efficient

AOP-11 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-12 What is an Aspect? Aspects are –Collection of crosscutting concerns in a system the crosscutting implementations –These are generally present among several layers or levels of class hierarchy in a OO system –Concerns that are orthogonal to the system

AOP-13 AOP vs. OOP AOP does not replace OOP It handles separation of concerns better than OOP Much like how OOP still uses concepts that are procedural, AOP uses concepts that are OOP It extends OOP AOP has –Functions, Classes and Aspects Procedural OOP AOP

AOP-14 Goals of AOP To –separate expression of behavioral concerns from structural ones –make design and code more modular not scatter the concerns though out your code –isolate the concerns for separate development and –be able to plug and unplug these concerns at will

AOP-15 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-16 What does AspectJ do? Code Aspect weave General purpose aspect oriented extension to Java –Developed at Xerox PARC

AOP-17 AspectJ Concepts & Constructs Join Point –well defined points in the execution flow of the code method calls –constructor invocation field access PointCut –selects certain join points and values at those points Advice –defines code that is executed when a pointcut is reached Introduction –modifies static structure –classes relationship

AOP-18 Aspect in AspectJ Module of crosscutting concerns Aspect PointCut Advice Introduction public aspect MenuEnabling { pointcut CreationOfMenuItem() : call(JMenuItem.new(..)); after() returning(JMenuItem item) : CreationOfMenuItem() { // advice definition code goes here } after() returning(JMenuItem item) : CreationOfMenuItem() {…} }

AOP-19 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-20 Pointcuts Defines arbitrary number of points in a program However, defines finite number of kinds of points –method invocation –method execution –exception handling –object instantiation –constructor execution –field reference

AOP-21 PointCut Designators execution –execution(void X.foo()) – when X.foo’s body executes call –call(void X.foo()) – when method X.foo is called handler –handler(OutOfMemoryException) – execution of the exception handler this –this(X) – object currently executing is of type X within –within(X) – executing code belongs to class X target –target(X) – target object is of type X cflow –cflow(void X.foo()) - This special pointcut defines all joint points between receiving method calls for the method and returning from those calls, i.e., points in the control flow of the call to X.foo()

AOP-22 PointCut Examples name-based crosscutting –call (void MyClass.foo(int)) any call to foo(int) on any object of MyClass –call (void MyClass1.f1(int)) || call (void MyClass2.f2(double)) any call to either f1 on object of MyClass1 or f2 on object of MyClass2 –pointcut pc1() : call (void MyClass.foo(int)) named pointcut with name pc1 property-based crosscutting ( not exact name ) –call (void MyClass.f*(..)) || call (* MyClass2.*(..)) void methods of MyClass starting with f or any method of MyClass2

AOP-23 PointCut Examples… pointcut pc3(X ref) : target(ref) && call(public * *(..)) –calls to any methods, on an object of X, with any args I want to find which methods of my class are invoked during a certain execution of my program

AOP-24 Eclipse Plugin Support You can find out crosscutting visually

AOP-25 call vs. execution In the case of a call, the context is in the caller of the method In the case of execution, the context is within the method of interest call will not capture super calls to non- static methods of the base, execution will Use call if you want an advice to run when the call is made. Use execution if you want an advice to run when ever a code is executed

AOP-26 Pointcut Context Execution context at the join point advice declarations may use these values pointcut pc2(MyClass obj, int a) : call (void MyClass.foo(int)) && target(obj) && args(a); after(MyClass obj, int a) : pc2(obj, a) { System.out.println(“method foo called on “ + obj + “ with arg “ + a); }

AOP-27 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-28 Advice Defines code that should run at join points Types of Advices: –Before runs when joint point is reached, but before computation proceeds –After runs after computation finishes and before the control returns to the caller –Around controls if the computation under joint point is allowed to run Example –before() : pc1() { the code to run }

AOP-29 Advice and call execution after() : call(int X.foo(int) {…} –executes after the call to X.foo(int), irrespective of successful completion or not after() returning(int result) : call(int X.foo(int){…} –executes after the successful completion of the call. The returned result may be accessed by advice definition after() throwing(Exception e) : call(int X.foo(int)) –executes only if foo throws exception of type Exception. After the advice runs, the exception is re-thrown.

AOP-30 Bypassing calls Using around you may bypass calls to methods You may check for conditions and let the call go though or simply refuse to allow the call as well around(X ref, int a) : call(int X.foo(int) && args(a) && target(ref) { if (a > 2) proceed(ref, a); return 4; }

AOP-31 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-32 Pitfalls While concept is very simple, syntax is confusing Has some learning curve, especially to implement some complex cross cuttings Easy to write a pointcut that puts your code in recursive calls – StackOverflowException Different tools for different languages

AOP-33 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ PointCut Advice Pitfalls Conclusion

AOP-34 Conclusion AOP seems to be the next logical step in handling –c–complexity –s–separation of concerns Has a lot of promise This is a beginning and not the end to the next phase of refinement

AOP-35 References 1. Aspect-Oriented Software Development: 2. Aspect J: 3. Aspect J Development Tools (Eclipse Plugin): 4. AOP Focus issue: Communications of the ACM, October Volume 44, Number Examples presented in this session may be downloaded from