0% found this document useful (0 votes)
59 views

Aspect Oriented Programming

Aspect oriented programming (AOP) is a programming paradigm that aims to increase modularity by separating cross-cutting concerns. AOP breaks program logic into distinct parts called aspects. Aspects provide cross-cutting functionality through join points, points in the code where advice can execute before, after, or around the join point. Weaving links aspects with other application objects to create advised objects. AOP has been implemented in many languages through native support or external libraries.

Uploaded by

Keren
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Aspect Oriented Programming

Aspect oriented programming (AOP) is a programming paradigm that aims to increase modularity by separating cross-cutting concerns. AOP breaks program logic into distinct parts called aspects. Aspects provide cross-cutting functionality through join points, points in the code where advice can execute before, after, or around the join point. Weaving links aspects with other application objects to create advised objects. AOP has been implemented in many languages through native support or external libraries.

Uploaded by

Keren
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

ASPECT ORIENTED

PROGRAMMING (AOP)
GROUP 5
• Aspect oriented programming (AOP) is one of the key components
of Spring Framework. Aspect-Oriented Programming has been around
in other programming languages for quite some time now and
sophisticated solutions taking advantage of AOP exist. It is
a programming paradigm that aims to increase modularity by allowing
the separation of cross-cutting concerns.
• Aspect-oriented programming entails breaking down program logic into
distinct parts (so-called concerns, cohesive areas of functionality). Nearly
all programming paradigms support some level of grouping
and encapsulation of concerns into separate, independent entities by
providing abstractions (e.g., functions, procedures, modules, classes,
methods) that can be used for implementing, abstracting and composing
these concerns. Some concerns "cut across" multiple abstractions in a
program, and defy these forms of implementation. These concerns are
called cross-cutting concerns or horizontal concerns
AOP Terminologies

• Aspect

This is a module which has a set of APIs providing cross-cutting


requirements. For example, a logging module would be called AOP
aspect for logging. An application can have any number of aspects
depending on the requirement.
• Join point

This represents a point in your application where you can plug-in the
AOP aspect. You can also say, it is the actual place in the application
where an action will be taken using Spring AOP framework.
• Advice

An advice is the action taken by an aspect at a particular join point.


This is the actual action to be taken either before or after the method
execution. Advices are implemented as methods of the aspect class.
This is an actual piece of code that is invoked during the program
execution by Spring AOP framework.
• Point cut

This is a set of one or more join points where an advice should be


executed. The pointcut defines a set of join points which need to be
matched before running an advice. You can specify point cuts using
expressions or patterns as we will see in our AOP examples.
• Introduction

An introduction allows you to add new methods or attributes to the


existing classes. By declaring an introduction it is possible to introduce
new interfaces and an implementation of the required methods
without touching the code of the original class. Additionally
introductions can be used to add new properties to a target class.
• Target object

A class or method being adviced by one or more aspects is referred to as


a target class /-method. The object being advised by one or more
aspects. This object will always be a proxied object, also referred to as
the advised object.
• Weaving

Weaving is the process of linking aspects with other application types or


objects to create an advised object. This can be done at compile time,
load time, or at runtime.
Types Of Advice
• Before advice

A before advice is executed before the target method is being called, but cannot prevent

the target method from being executed.

• After returning advice

An after returning advice is executed after returning from the target method. The result of

the target method invocation is available to the after returning advice, but it can’t change

it. If the target method throws an exception, the after returning advice is not executed.
• After throwing advice

An after throwing advice is only executed if the target method throwed an


exception. The after throwing advice may fetch the exception type from
the join point object.

• After advice

An after advice is executed after the target method has been called, no
matter if an exception was thrown or not.
• Around advice

An around advice is wrapped around the execution of the target method. It may

execute code before and after the invocation of the target method and may

ultimately prevent the original method from being executed at all. An around

advice is also responsible for calling other around advices at the same join point

and returning either the original or a modified result for the target method.
• Advice chain

If more than one around advice exists for a join point, they are called in an

onion-like advice chain: The first around advice probably executes some before-

code, then calls the second around advice which calls the target method. The

target method returns a result which can be modified by the second around

advice, is returned to the first around advice which finally returns the result to

the initiator of the method call. Any around advice may decide to proceed or

break the chain and modify results if necessary.


PROGRAMMING LANGUAGES USED IN
AOP
The following programming languages have implemented AOP, within the language, or
as an external library:

• .NET Framework languages (C# / VB.NET)

• PostSharp is a commercial AOP implementation with a free but limited edition.

• ActionScript

• Ada

• AutoHotkey]
• The Cocoa Objective-C frameworks

• ColdFusion

• Common Lisp

• Delphi

• Delphi Prism

• Emacs Lisp

• Groovy

• Haskell

• Java
• C/ C++

• COBOL

• JavaScript

• Logtalk

• Lua

• make

• Matlab

• ML

• Perl
• PHP

• Prolog

• Python

• Racket

• Ruby

• Squeak Smalltalk

• UML 2.0

• XML

You might also like