Aspect-Oriented Programming An Introductory Presentation Mike Landi MSCS Candidate Union University.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
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.
Object-Oriented Software Development CS 3331 Fall 2009.
An Aspect-Oriented Approach For Web Application Access Control Presented by: Mohamed Hassan Carleton University Carleton University
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 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.
Ch3: Software Engineering Principles 1 What is a principle?  Definition:  Goals of accounting principles:  Goals of software engineering principles?
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 FM Overview of Adaptation. 2 FM RAPIDware: Component-Based Design of Adaptive and Dependable Middleware Project Investigators: Philip McKinley, Kurt.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Introduction to AOP.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
1 N Degrees of Separation: Multi-Dimensional Separation of Concern (MDSOC) HyperJ: language and concepts of general concern combination.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
An Introduction to Software Architecture
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)
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
Composing Adaptive Software Authors Philip K. McKinley, Seyed Masoud Sadjadi, Eric P. Kasten, Betty H.C. Cheng Presented by Ana Rodriguez June 21, 2006.
©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 Programming Gülşah KARADUMAN.
Joel Phinney March 31, ◦ Concerns  Separation of Concerns, Tangled and Scattered Concerns, Cross-Cutting Concerns, Aspects ◦ Aspect-Oriented Software.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Introduction Better Faster Cheaper (pick any two) On-going issue that continues to motivate research in software engineering Applications: –continue to.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Adaptive Software Kevin Cella Graduate Seminar 02/04/2005.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
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.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Introduction to OOP CPS235: Introduction.
Advanced Software Development Karl Lieberherr CSG 260 Fall Semester
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
Introduction to Yan Cui Aspect Oriented Programming by
R R R A Brief Introduction to Aspect-Oriented Programming.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Aspect-Oriented Software Development (AOSD)
Basic Characteristics of Object-Oriented Systems
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
SE 510 Principles and Applications of Software Design Aspect Oriented Programming October 5, 2005 Jeff Webb.
Software Engineering Lecture 7
Algorithms and Problem Solving
Visit for more Learning Resources
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
About the Presentations
Discussion with Gregor Kiczales at UBC
Demeter Aspects Who We Are Aspectual Collaborations
Aspect-Oriented Programming
An Introduction to Software Architecture
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Aspect-oriented programming
AspectAda Aspect-Oriented Programming for Ada95
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
Aspect Oriented Software Design
Presentation transcript:

Aspect-Oriented Programming An Introductory Presentation Mike Landi MSCS Candidate Union University

2 Objectives Evolution of Programming Paradigms AOP as a Next Step Tools Additional Information Discussion

3 Evolution of Programming Paradigms

4 Programming Paradigms Machine Code Assembly Language Programming Procedural Programming Functional Programming Logic Programming Object-Oriented Programming

5 Assembly Languages Provide Mechanism for Abstraction of the Underlying Machine

6 Procedural Language Programming Structured Programming Functional Units are Implemented as Procedures or Functions Modularity Reusability of Code

7 Object-Oriented Programming Coding that Mimics Real World Based on the Notion of an Object Functional Units are Represented as Objects Objects most often Implemented as Classes Principles of Inheritance, Encapsulation, and Polymorphism Enhanced Modularization Enhanced Code Reuse

8 Historical Perspective Each new Programming Paradigm has provided us with additional mechanisms for abstraction and composition.

9 Design and Implementation Design Processes Enable us to Break a System Down into Smaller Units Programming Languages Provide Mechanisms that allow us to … Define Abstractions of System Sub-Units Compose Abstractions in different ways to Produce the Overall System

10 Design and Implementation Design Processes and Programming Languages work well together when the programming language provides abstraction and composition mechanisms that cleanly support the kinds of units the design process breaks the system into.

11 Generalized-Procedure Languages OOP, Procedural, and Functional Languages Support Functional Decomposition Break Systems Down in Terms of Units of Behavior or Function Software Engineering Concept introduced by Parnas

12 Limitation of GP Languages GP Languages do not adequately address Non-Functional Units of a System Co-composition of Functional and Non- Functional Units must be done manually Leads to Complexity, and Tangling and Scattering of the Code

13 AOP as a Next Step

14 Origin of AOP AOP was developed during the 1990s by researchers at Xerox PARC Borne out of research to extent OOP capabilities

15 What is AOP? AOP is a programming methodology for addressing crosscutting concerns in a system, at both the design and implementation levels. AOP seeks to separately specify the various concerns of a system, and then to "weave" or compose them together into a coherent program. AOP is an additional technique, not a replacement for OOP.

16 What is a Concern? A particular Goal, Concept, Behavior, or Area of Interest … Two Types of Concerns Basic Concerns Specify what is really important to an application AKA … Functional, Common, Core or Domain Specific Concerns Special Concerns Used to manage or optimize Basic Concerns AKA … Non-Functional or Crosscutting Concerns

17 Separation of Concerns Emerging Paradigm Discussed by Cristina Lopes, Northeastern University, 1995 Two Types of Concerns Basic - Relevant to Application Domain Special Purpose - Crosscutting Seeks to Formally Separate the Basic Algorithm from Special Concerns Prior to AOP Functional Decomposition only Separated Basic Concerns from other Basic Concerns

18 Concept of Composition Once concerns are separated and independently implemented, all of the associated code has to be composed into one coherent final program OOP uses Object Reference, Inheritance, and Message Sending for Composition AOP Systems Use One of the Following Techniques for Composition Meta-Level Programming Composition Filters Pattern-Oriented Programming

19 What is a Crosscutting Concern? Concerns that Cut Across Typical Divisions of Responsibility Concerns that Cut Across Functional Decomposition Concerns that Affect Multiple Classes

20 Examples of Crosscutting Concerns Logging & Debugging Error Handling Performance Optimizations Minimizing Network Traffic Synchronization Caching and Buffering Security Resource-Pool Management Transaction Management Design by Contract

21 What is an Aspect? An AOP Programming Construct Allows programmers to handle Crosscutting Concerns as Separate Single Entities

22 Properties of Aspects Robust Change to one aspect should have a limited impact on other aspects Systemic Aspects should affect the target program at many different places Cross-Cutting Each Other Information about one aspect will be mixed with information about other aspects in target program

23 Properties of Aspects Loosely Coupled An aspect should not know the details of other aspects Contain Join Points Used to weave the aspects with target programs

24 Crosscutting Concern Detailed Example Information Delivery Service Music Pay-Per-View TV Magazines Charges Made Differently by Content Type Song – Charge after 51% Saved or 100% Played Show – Charge after First Episode Delivered Magazine – Charge after Article Printed and Mailed

25 Crosscutting Concern Detailed Example

26 Crosscutting Concern Detailed Example OOP Implementation of Crosscutting Concerns Results in … Tangled and Scattered Code Poor Traceability Lower Programmer Productivity Less Code Reuse Poor Code Quality Less Evolvable Code

27 Crosscutting Concern Detailed Example An AOP Alternative … Separate the Payment Crosscutting Concern from the Application Domain Classes Remove Charge Methods from Song, Show and Magazine Classes Capture Code from All Charge Methods in a Single Aspect Establish rules for Composition of the Aspect with the OOP Classes Join Points, Pointcuts and Advices

28 Structural Elements of AOP System Component Language OO Language (or not) Aspect Language Language Aspects are Programmed In Aspect Weaver Accepts Component and Aspect Programs as Input Performs Co-composition of the two into one Combined Final Program

29 How AOP Works Join Point Model Model that Specifies How Composition Will Be Done Which AOP Composition Mechanism Will Be Used Makes It Possible for Combined Program to Execute Properly Join Points Well Defined Points in the Execution of Component Program Examples: Method Call or Exec, Constructor Call or Exec, Field Reference, Field Assignment, others …

30 How AOP Works Pointcuts Syntactic Construct Used to Detect Join Points Specifies a Set of Join Points Can Optionally Specify Values in Execution Context of those Join Points Advices Method-Like Mechanisms to Declare Code that Should Run at Specified Join Points Code Runs when Join Point Reached at Runtime AspectJ Advices … Before, After, and Around

31 How AOP Works More on Pointcuts and Advices (AspectJ) Associated Parameter Mechanism Allows Advice to See Subset of Values in Execution Context of Join Points Access to Return Values (of Methods in Component Program) Inheritance and Overriding of Advices and Pointcuts

32 System Development With AOP Aspectual Decomposition Decompose Requirements to Identify Crosscutting and Common Concerns Concern Implementation Common Concerns in Component Language Crosscutting Concerns in Aspect Language Aspectual Re-composition Specify Re-composition Rules (Join Points, Pointcuts, Advices) for Use by Aspect Weaver

33 System Development With AOP

34 Crosscutting Concern Detailed Example

35 Crosscutting Concern Detailed Example More Detailed Outline for AOP Solution Remove all charge methods from OOP Classes Create a Payment Aspect to contain the specialized code for the Payment Crosscut charge methods for the Song, Show, and Magazine classes Add four Pointcuts to the Aspect to define Join Points Two for Song (51% Played or 100% Saved) One each for Show & Magazine Add the specialized code for charge specifics for Song, Show, and Magazine to the Aspect Each piece of specialized code has an Advice of its own that will execute when its Join Point is reached at Runtime

36 Crosscutting Concern Detailed Example

37 Crosscutting Concern Detailed Example public aspect Payment { pointcut song_play_charge():execute(void Song.play*(..)); pointcut song_save_charge():execute(void Song.saveToDisk*(..)); pointcut show_charge():execute(void Show.delivered*(..)); pointcut magazine_charge():execute(void Magazine.mail*(..)); after():song_play_charge() { {// Song play charge specialized code here … } after():song_save_charge() { {// Song save charge specialized code here … } after():show_charge() { {// Show charge specialized code here … } after():magazine_charge() { {// Magazine charge specialized code here … } }

38 AOP Simple Logging Example

39 AOP Simple Logging Example AspectJ Compile Commands Aspects can be easily plugged into or out of an application Compile App with Aspect ajc Point.java ShowAccesses.java Compile App without Aspect ajc Point.java To get some info on what ajc is doing ajc –preprocess Point.java ShowAccesses.java

40 AOP for Design By Contract DBC Requires Explicit Contracts Hold True at Various Execution Points Before an Operation After an Operation AOP can enforce DBC … Create Aspects Containing Pointcuts and Advices Advices Check Contracts at Execution Points Execution Points Defined by Pointcuts

41 AOP Versus OOP Where they are Related and Similar AOP Works in Conjunction With OOP AOP is an Additional Technique Not a Replacement for OOP AOP does for crosscutting concerns what OOP has done for object encapsulation and inheritance

42 AOP Versus OOP Where they are Different AOP works on Crosscutting Concerns, OOP on Common Concerns AOP attempts to realize scattered concerns as first-class elements, and ejects them horizontally from the Object Structure … OOP finds commonality among classes and pushes it vertically up in the Inheritance Tree Modularization Unit of AOP is an Aspect, Modularization of OOP is a Class

43 Benefits of AOP Modularization of Crosscutting Concerns Implementation Looks More Like Design Easier Development and Maintenance Simplifies Code (Rmv Tangling Scattering) Greater Potential for Reuse of Code Smaller Software More Evolvable Software

44 Quantifying the Benefits

45 The Power of the AOP Approach Application code is easier to reason about Easier to understand components and how they compose They are not cluttered with Aspects Easier to understand Aspects and how they compose They are not tangled with other Aspects in Component Code Easy to understand the effect of Aspects on Combined Output Code Aspect Weaver handles details of Integration of Component and Aspect Code Changes to Aspect Code are easily integrated by Re- Weaving

46 Long-term Promise of AOP Easier coding and maintenance of crosscutting concerns, and elimination of scattered and tangled code surrounding such concerns, will make way for less buggy upgrades, shorter product cycles, and ultimately better and less expensive software.

47 Does AOP Work? Easier to Build AOP System when Interface Between Aspects and Component Code is Narrow and Unidirectional Narrow – Aspect Code has well-defined effect on points in Component Code Unidirectional – Aspect Code Refers to Component Code but not vice versa Have Determined Situations Where AOP Benefits Developers More Studies Needed to Qualify and Quantify Benefits of AOP

48 Issues Component Programs must not preempt Aspect Programs Component Program must avoid handling any concerns being handled by Aspect Program What Composition Mechanisms are provided? Can Aspects be applied to different types of concerns? Is the Aspect Language Domain Specific or General- Purpose? Are Aspect Visible to Each Other?

49 Issues Aspect Precedence What mechanisms provided to resolve conflicts among multiple aspects advising same Join Point? How are Aspects Specified? Interactions between Aspects and Components How Join Points are defined Component Program requirements for specifying points to be joined to

50 Issues Implementation Mechanisms Are Compositions determined statically at compile time or dynamically at runtime? Can compilations be done incrementally? Does the compiler require source code or can it work with byte code? Are there mechanisms for verifying compositions? Reusability of Aspects Need to develop ways to work with large numbers of Aspects and to build large libraries of Aspects

51 Issues Decoupling Obliviousness – Does Component Program need to be aware that Aspects are being applied to it? Intimacy – What has to be done to prepare Component Code for Aspects? Globality vs Locality – Do Aspects apply to the Component Program as a whole or only to parts of it? Software Development Process Need to devise a complete AOP Software Engineering Process How does AOP impact Overall Design Complexity?

52 Tools

53 AspectJ First Production Quality General Purpose AOP Language Release 1.0 Made Available June 2001 Seamless Extension to Java Compiler Produces Standard Java Byte Code Maintains Java’s Advantages Compiler Can Be Used to Easily Plug Aspects Into or Out of Overall Application

54 AspectJ Component Language is Java Aspect Language is AspectJ Aspect Weaver is AspectJ Compiler ajc

55 AspectJ

56 Other Tools AspectC++ A Set of C++ Language Extensions to Facility AOP with C++ AspectC AOP Extension to C Support OS and Embedded System Programming Taken From Non-OO Subset of AspectJ FEAT Tool to locate, describe, and analyze concerns in existing source code Engineering of aspects from existing code

57 Additional Information

58 The People Behind AOP Gregor Kiczales Professor of Computer Science - University of British Columbia (Since 1999) Graduate of M.I.T. (1983) Research Scientist at Xerox PARC ( ) Co-Founder of Group that Developed AOP and Started Aspectj.Org

59

60 The People Behind AOP Cristina Lopes Professor of Computer Science – University of California (Since Fall 2002) PhD in Philosophy, Northeastern University (1997) Wrote First PhD Thesis on AOP Research Scientist at Xerox PARC Co-Founder of Group that Developed AOP and Started Aspectj.Org

61

62 Conferences Aspect-Oriented Software Development (AOSD) European Conference for Object-Oriented Programming (ECOOP) Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA) International Conference on Software Engineering (ICSE) International Symposium on Object Technologies for Advanced Software (ISOTAS)

63 Topics Discussed at AOSD 2003 Making the Code Look Like the Design Architectural Views of Aspects Modularization and Composition of Aspectual Requirements AspectC++ Back to the Future: A Retroactive Study of Aspect Evolution in OS Code AspectJ FEAT – A Tool for Locating, Describing, and Analyzing Concerns Source Code

64 M.I.T. Technology Review Top 10 Brain-Machine Interfaces Flexible Transistors Data Mining Digital Rights Management Biometrics Natural Language Processing Microphotonics Untangling Code (AOP) Robot Design Microfluidics

65 Discussion