Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.

Similar presentations


Presentation on theme: "Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech."— Presentation transcript:

1 Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.

2 19 August 2005Aspect Oriented Programming2 Contents Introduction AOP Methodology AOP Languages AspectJ

3 19 August 2005Aspect Oriented Programming3 Programming Methodologies m/c Programming Assembly Programming Procedural Programming OO Programming AO Programming Programming Methodologies Evaluation Concern Abstraction Function Abstractio n Object Abstraction Introduction

4 19 August 2005Aspect Oriented Programming4 Present Design Problem The architect’s dilemma –How much design is too much? Introduction

5 19 August 2005Aspect Oriented Programming5 Terminology Concern – A specific requirement or consideration that must be addressed in order to satisfy the overall system goal –E.g. Banking system: Customer and Account management, Interbanking transactions, ATM transactions, Persistence of all entities, Transaction integrity, Authorization of access to various services, Logging, Security, Error checking, Policy enforcement Introduction

6 19 August 2005Aspect Oriented Programming6 Terminology cont Core concerns –Central functionality of a Business logic (single module) –Customer and Account management, Interbanking transactions, ATM transactions Crosscut concerns –System-level, peripheral requirements (multiple modules) –Persistence of all entities, Transaction integrity, Authorization of access to various services, logging, Security, Error checking, Policy enforcement Introduction

7 19 August 2005Aspect Oriented Programming7 Typical Application Accounting ATM Database System Introduction Persistence Logging Business Logic Concern Persistence Logging Implementation modules Accounting ATM Database System Persistence Logging

8 19 August 2005Aspect Oriented Programming8 Implementation by Traditional Languages Accounting Module ATM Module Database Module Logging Module API invocations Introduction

9 19 August 2005Aspect Oriented Programming9 Implementation by AOP Accounting Module ATM Module Database Module Logging Module Logging Aspect API Invocation Automatically Weaving Invocations Aspect: A modular unit of crosscutting concern implementation Introduction

10 19 August 2005Aspect Oriented Programming10 AOP Methodology The idea behind AOP is “Separation of concern” AOP builds upon Existing Methodologies (OOP, Procedural programming), augmenting them with concepts and constructs in order to modularize crosscutting concerns. Now, concern consists of what? AOP Methodology

11 19 August 2005Aspect Oriented Programming11 AOP Development Stages AOP Methodology Business Logic Security Logging Persistence Identify concerns Integrating all concerns

12 19 August 2005Aspect Oriented Programming12 AOP Languages AOP Language Specification –Describes the language constructs and syntax –Specification for implementing the individual concerns and rules for weaving different concerns AOP Languages

13 19 August 2005Aspect Oriented Programming13 AOP Languages cont AOP language implementation –Verifies the code and translates the code into an executable form –Implementation done by two steps Combining individual concerns using the weaving rules - Weaving Then converting result into executable code. Some AOP Languages –AspectJ, Aspect#, AspectC++, PHPaspect. AOP Languages

14 19 August 2005Aspect Oriented Programming14 AspectJ Aspect-oriented extension to Java language Language Specification Language Implementation –Concern by Java Language –Weaving rules by extension Tools Crosscutting in AspectJ –Implementation of the weaving rules by the compiler –2 Types: Dynamic Crosscutting –Weaving of new Behavior into execution of program Static Crosscutting –weaving of modifications into the static structure, to support the Dynamic Crosscutting AspectJ

15 19 August 2005Aspect Oriented Programming15 AspectJ cont Crosscutting Elements –Join Point Well-defined points in the execution of a program –Pointcut A means of referring to collections of join points and certain values at those join points –Advice Method-like constructs to define additional behavior at join points –Introduction Instruction that changes to the classes, interfaces of the system –Compile time Declaration Instruction for adding compile time warnings and errors to the system –Aspect Unit of modular crosscutting implementation AspectJ

16 19 August 2005Aspect Oriented Programming16 Example Public class Logging{//class public void check( ) { System.out.println("Inside Logging Class Method"); }} public class ATM { //class public void foo(int number, String name) { System.out.println("Inside foo Method"); } public static void main(String[] args) { MyClass myObject = new MyClass( ); myObject.foo(1, “SIT"); } } public aspect Log { //Aspect pointcut callPointcut( ) : call(void ATM.foo(int, String)); //Pointcut before( ) : callPointcut( ) { //Advice System.out.println( “I am from Log aspect"); Logging logg= new Logging(); logg.check(); } } AspectJ Name of Pointcut before after around

17 19 August 2005Aspect Oriented Programming17 Example cont Compile –ajc ATM.java Log. java –output: ATM.class Log.class Run –java ATM –Output: I am from Log aspect Inside foo Method Here let us assume Logging class already compiled AspectJ

18 19 August 2005Aspect Oriented Programming18 References AspectJ Cookbook, O'Reilly, December 2004 Aspectj In Action - Practical Aspect-Oriented Programming, 2003 http://www.codeproject.com/gen/design/aop.asp#2 http://en.wikipedia.org/wiki/Aspect_oriented_programming Erik Putrycz, Guy Bernard, IEEE 2002, Using Aspect Oriented Programming to build a portable load balancing service


Download ppt "Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech."

Similar presentations


Ads by Google