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

Aspect Oriented Programming

This document introduces aspect-oriented programming (AOP). AOP aims to separate cross-cutting concerns, like logging and error handling, from core concerns to reduce tangled code. It works by defining aspects that specify what code to run before, after, or around joins points, like method calls. Pros are reduced code and automatic application of aspects. Cons can include complexity from separating concerns and violating the single responsibility principle.

Uploaded by

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

Aspect Oriented Programming

This document introduces aspect-oriented programming (AOP). AOP aims to separate cross-cutting concerns, like logging and error handling, from core concerns to reduce tangled code. It works by defining aspects that specify what code to run before, after, or around joins points, like method calls. Pros are reduced code and automatic application of aspects. Cons can include complexity from separating concerns and violating the single responsibility principle.

Uploaded by

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

ASPECT ORIENTED PROGRAMMING

Presented by: Joshua Elliott

INTRODUCTION

What is it?
Examples
Pros - Cons

WHAT IS IT?

Boring definition terms.


What about OOP?
What does AOP set out to accomplish?
How does it do this?

EXAMPLE

Graphics update
Logging

EXAMPLE CODE
// HelloWorld.java public class HelloWorld {
public static void say(String message) {
System.out.println(message);
}
public static void sayToPerson(String message, String name) {
System.out.println(name + ", " + message);
}
}

// MannerAspect.java
public aspect MannersAspect{
pointcut callSayMessage() : call (public static void HelloWorld.say*(..));
before() : callSayMessage() {
System.out.println (Good day!);
}
after() :callSayMessage() {
System.out.println (Thank you!);
}
}

PROS & CONS

Reduces the amount of code to


write
It is auto-magically applies to
future code
It reduces clutter

Can be confusing

Breaking the rule of Action at a Distance

QUESTIONS?

Question 1: What is a pointcut?


Question 2: What is one concern that can be
seen as negative for AOP?
Bonus questions from you!

CITATION

Base Material provided from the following two websites:

http://www.cs.ubc.ca/~gregor/papers/kiczales-ECOOP1997-AOP.pdf
https://msdn.microsoft.com/en-us/library/aa288717(v=vs.71).aspx

Example code retrieved from: http


://www.javaworld.com/article/2074048/core-java/i-want-my-aop---part-2.html

Detailed Citation provided in Notes section of this page

You might also like