You are on page 1of 20

Aspect Oriented Programming

Presented by:

Anumod Kumar S
CS-7
7211
Introduction

• Currently, the dominant programming paradigm is


object-oriented programming that:
has been presented as a technology that
can fundamentally aid software engineering
 is reflected in the entire spectrum of
current software development
methodologies and tools
• Object orientation is a clever idea, but has certain
limitations
Aspect Oriented Programming 1
Aspect Oriented Programming
• What is it?
– Programming methodology that modularizes code
into processes.
• What does it do?
– Aids programmers in the separation of
concerns/processes, specifically cross-cutting
concerns, as an advance in modularization.

Aspect Oriented Programming 2


Object Oriented Programming
• What is it?
– Programming methodology that modularizes code
into objects.
• What does it do?
– Aids programmers in separation of code into real
world objects.

Aspect Oriented Programming 3


Object Oriented Programming
• Components of OOP
– Class
• Component that modularizes code in OOP.
– Function
• Contained inside a class.
• Performs a process.
– Manipulates objects, attributes, etc.

Aspect Oriented Programming 4


Object Oriented Programming
• Advantages of OOP.
– Modularizes code into real world objects.
• Easy to understand code.
– Code is reusable if modularized correctly.
– Code is easily maintained due to fix once, use
everywhere principle.
– Many development methodologies lend
themselves to OOP.

Aspect Oriented Programming 5


Object Oriented Programming
• Disadvantages of OOP.
– Does not address cross-cutting concerns.
• Processes/Functionality cross into many code
modules.
• Creates duplicate code if not addressed.
– Unaddressed cross-cutting concerns may be
hard to maintain.

Aspect Oriented Programming 6


Object Oriented Programming
• Similarities between AOP and OOP.
– Take advantage of code modularization.
• Code Reusability
• Code Maintainability
• Differences between AOP and OOP.
– OOP modularizes on basis of real world
objects.
– AOP modularizes on basis of
Processes/Functionalities.

Aspect Oriented Programming 7


Need for AOP
• Problems with traditional Object Oriented
Programming approach.
– OOP divides processes into classes, or
objects.
– These classes often cross over into many
different processes.
• Leads to duplicated code.
• Hard to maintain code.
• Hard to use code.

Aspect Oriented Programming 8


Traditional OOP Approach
Fruit
Shape
Color
Size

Apples Oranges Bananas

Storage Storage Storage


Sell Sell Sell
Buy BuyConcerns
Crosscutting Buy

Aspect Oriented Programming 9


Need for AOP
• Aspect Oriented Programming approach
addresses cross cutting concerns.
– Better separates processes (concerns) than
previous approaches.
• Creates cleaner code
• Code is reusable at a greater extent than OOP
• Properly separates business requirements
into clean reusable code/

Aspect Oriented Programming 10


Advantage of AOP
• Currently with OOP, implementation is forced on
developer
– Developer must implement requirements ahead of
time.
– Often time, developer is not clear on requirements up
front.
• Problem solved by AOP.
– Implementation can be held off until clear.
– Bad implementation is eliminated due to unclear
requirements.

Aspect Oriented Programming 11


Aspects
• In AOP crosscutting concerns are implemented
in aspects instead of fusing them into core
modules.
• Aspects are an additional unit of modularity.
• Aspects can be reused.
• By reducing code tangling it makes it easier to
understand what the core functionality of a
module is.
• An “aspect weaver” takes the aspects and the
core modules and composes the final system.

Aspect Oriented Programming 12


AOP Key Idea

base/core program
weave

final system

aspect
Aspect Oriented Programming 13
Aspect weaving

• Composition mechanism that coordinates


aspects with the other modules of the
system.

• Performed by a specialized compiler


called Weaver.

Aspect Oriented Programming 14


Before AOP
Financial Timecard Scheduling

Transaction Transaction Transaction


Security Security Security
Crosscutting Concerns

After AOP

Financial Timecard Scheduling

Transaction Security

Aspect Oriented Programming 15


Conclusion
• Important to remember that AOP is not
replacing OOP, but enhancing it.
– Can utilize OOP and AOP at same time.

• AOP approach involves not only technical


changes, but methodology changes.
– Process oriented instead of Object oriented.

Aspect Oriented Programming 16


References:

• Wikipedia the free Encyclopedia http://www.wikipedia.com


• Aspect-Oriented Programming, Gregor Kiczales, John Lamping,
Anurag Mendhekar, Chris Maeda, Cristina Videira Lopes, Jean-
Marc Loingtier, John Irwin
• Aspect-Oriented Programming with Model Checking, Naoyasu
Ubayashi, Systems Integration Technology Center, Toshiba
Corporation, Tokyo, Japan
• An Initial Assessment of Aspect-oriented Programming,Robert
J.Walker, Elisa L.A. Baniassad and Gail C. Murphy, Dept. of
Computer Science, University of British Columbia, 201-2366 Main
Mall, Vancouver, BC V6T 1Z4 Canada

Aspect Oriented Programming 17


QUESTIONS

Aspect Oriented Programming 18

You might also like