0% found this document useful (0 votes)
44 views28 pages

Aspect Oriented Programming: Ramya - R

Aspect Oriented Programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. AOP addresses behaviors that span multiple, unrelated modules. In AOP, cross-cutting concerns are implemented in aspects instead of being scattered throughout code. Aspects define pointcuts that specify join points in a program, and advice that defines the actions to be taken at those join points. An aspect weaver combines aspects and code into an executable form. AspectJ is a popular AOP extension for Java that enables modular implementation of cross-cutting concerns.

Uploaded by

Ramya Raj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views28 pages

Aspect Oriented Programming: Ramya - R

Aspect Oriented Programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. AOP addresses behaviors that span multiple, unrelated modules. In AOP, cross-cutting concerns are implemented in aspects instead of being scattered throughout code. Aspects define pointcuts that specify join points in a program, and advice that defines the actions to be taken at those join points. An aspect weaver combines aspects and code into an executable form. AspectJ is a popular AOP extension for Java that enables modular implementation of cross-cutting concerns.

Uploaded by

Ramya Raj
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Aspect Oriented Programming

Presented By:

RAMYA . R
Programming paradigms
 Procedural programming
 Executing a set of commands in a given sequence
 Fortran, C, Cobol
 Functional programming
 Evaluating a function defined in terms of other functions
 Lisp
 Logic programming
 Proving a theorem by finding values for the free variables
 Prolog
 Object-oriented programming (OOP)
 Organizing a set of objects, each with its own set of responsibilities
 Java, C++ (to some extent)
 Aspect-oriented programming (AOP)
 Executing code whenever a program shows certain behaviors
 AspectJ (a Java extension)
Introduction

 Currently, the dominant programming paradigm


is object-oriented programming for many
salient features.

 Object orientation is a clever idea, but has


certain limitations
Limitations
 Some programming tasks cannot be neatly
encapsulated in objects, but must be scattered
throughout the code.

 Examples:
 Tracing (determining what methods are called
when)
 Session tracking, session expiration

 The result is crosscuting code--the necessary


code “cuts across” many different classes and
methods.
Origins
 AOP has several direct antecedents
reflection and meta object protocols,
subject - oriented programming .

 Gregory Kiczales and colleagues at 


Xerox PARC developed the explicit
concept of AOP in the 1990’s.
What is AOP ?
 AOP is a program paradigm which aims
to increase modularity but allowing
separation of cross-cutting concerns.

 It form a basis for aspect oriented


software development.

 It addresses behaviors that span many,


often unrelated, modules.
Motivation for AOP
 Typical programs often have behavior
that doesn't fit into a single module.
 “Code Tangling”
Accounting

XML Parsing

Logging

Database
Concern
 Concern – is a particular goal, concept, or
area of interest. An engineering process
deals with many concerns.
 It can range from high-level notion to
low level-notion.
 It can be functional or nonfunctional
(systemic).
Types of concerns

 Core Concerns:
 Primary core functionality.
 Central functionality of a module.

 Crosscutting Concerns:
 System wide concerns that span multiple modules.
 Cuts across the typical division of responsibility.
Crosscutting Concerns
 Crosscutting concerns – concerns that in
conventional implementations cannot be
implemented without scattering code.

 Even though most classes in an OO


model will perform a single, specific
function, they often share common,
secondary requirements with other
classes.
Example of crosscutting concerns

Display

*
Figure FigureElement

Point Line
getX() 2
getP1
getY() setP1
setX(int) setP1(Point)
setY(int) setP2(Point) DisplayUpdating
Terminology

 Join point

 Point cut

 Advice

 Aspect
Join points
 A join point is a well-defined point in the
program flow.

 Only those points that can be used in a


disciplined and principled manner.
Examples:
When a method is called
When an exception is thrown
When a variable is accessed
Point cuts
 Picks out join points.

 Can be defined in classes or in aspects


and can be named or be anonymous.

 Example pointcut:

pointcut setter(): call(void setX(int));


Advice
 Advice is a method like construct that expresses the
action to be taken at the join points that are captured
by a pointcut.

 Three types:

 Before advice

 After advice

 Around advice
Aspect
Crosscutting concerns are implemented
in aspects instead of fusing them into core
modules.

 Aspects can be reused.

By reducing code tangling it makes it


easier to understand.
What about encapsulation
 AOP breaks encapsulation in a controlled manner.

 Encapsulation is broken between classes and


aspects.

 Aspects marked as privileged have access to the


private members of a class.

 Encapsulation is preserved between classes.

 An aspect encapsulates a crosscutting concern.


Aspects are similar to classes

 have type
 can extend classes and other aspects
 can be abstract or concrete
 can have fields, methods, and types as
members
Aspect are different than classes

 can additionally include as members


point cuts , advice
 do not have constructor or finalizer
 no new operator.
 privileged aspects can access private
members of other types
Aspect weaver
 First implement using OO language.

 Then, implement aspects using AOP.

 Finally , both the code and aspects are


combined into a final executable form
using an aspect weaver
Compilation process
Aspectj
 Aspectj is:
 a general-purpose Ao extension to Java
 Java platform compatible
 easy to learn and use
 freely available under an Open Source license

 It enables the modular implementation of a


wide range of crosscutting concerns.
Pros and Cons
What next ?
 SE researchers provide some help to determine if
it is beneficial for sw development organization
to adopt AOP for building their sw products

 Three areas emerge as important in supporting


the use of AOP:
 exposing join points
 managing aspect interface
 structuring aspects
Conclusion
 AOP has many potential benefits.
 Higher modularization.
 Cleaner responsibilities for individual modules.
 Improved separation of concerns.
 Easier system evolution. Much easier to add
crosscutting functionality.
 More code reuse.
 Can make code easier or harder to understand.
 Already starting to become mainstream.
 Like all new technologies, AOP may--or may
not--catch on in a big way
QUERIES
References
 Lesiecki, Nicholas. “Improve modularity with aspect oriented
programming”. IBM Developer works, January,2002.

 Laded, Ramnivas. AspectJ in Action. Greenwich, Conn.: Manning


Publications, 2003.

 http://en.wikipedia.org/wiki/Aspect-oriented_programming

 AOP Homepage of Xerox PARC : http://www.parc.xerox.com/aop

 http://www.developer.com/lang/article.php/3308941/Aspect-
Oriented-Programming.htm

 http://www.aopworld.com
THANK U

You might also like