Lecture Slides on Aspect-Oriented Programming | CSCE 531, Study notes of Computer Science

Material Type: Notes; Class: COMPILER CONSTRUCTION; Subject: Computer Science & Engineering; University: University of South Carolina - Columbia; Term: Spring 2008;

Typology: Study notes

Pre 2010

Uploaded on 09/02/2009

koofers-user-cos
koofers-user-cos 🇺🇸

10 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction
Features
Class Example
Conclusion
Terminology
Concerns
Examples
An Overview of Aspect-Oriented Programming
Presented by
Jarrell W. Waggoner
College of Engineering and Computing
University of South Carolina
03/19/08
Presented by Jarrell W. Waggoner An Overview of Aspect-Oriented Programming
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Lecture Slides on Aspect-Oriented Programming | CSCE 531 and more Study notes Computer Science in PDF only on Docsity!

Features Class Example Conclusion

Terminology Concerns Examples

An Overview of Aspect-Oriented Programming

Presented by

Jarrell W. Waggoner

College of Engineering and Computing

University of South Carolina

Features Class Example Conclusion

Terminology Concerns Examples

Terminology of Aspect-Oriented Programming (AOP)

Term: Concern

Definition: A feature or essential operation that is part of a

larger program or solution

Features Class Example Conclusion

Terminology Concerns Examples

Terminology of Aspect-Oriented Programming (AOP)

Term: Concern

Definition: A feature or essential operation that is part of a

larger program or solution

Term: Code Entanglement

Definition: Code that cannot be separated into more than one

concern

Term: Cross-Cutting Concern

Definition: A concern that is entangled with one or more other

concerns

Features Class Example Conclusion

Terminology Concerns Examples

Division of Concerns

How concerns are divided in different paradigms:

Functional Programming ⇒ Functions

Object-Oriented Programming ⇒ Objects

Functions: Code separation

Objects: Concern separation

Features Class Example Conclusion

Terminology Concerns Examples

Cross-Cutting Concern Examples

List of cross-cutting concerns:

System logging and tracing

Error handling

Statistics gathering

Security handling

Managed garbage collection

Features Class Example Conclusion

Terminology Concerns Examples

Cross-Cutting Concern Examples

List of cross-cutting concerns:

System logging and tracing

Error handling

Statistics gathering

Security handling

Managed garbage collection

Most OOP languages are extended to support Aspect-Orientation

rather than creating entirely new languages:

Common Lisp ⇒ AspectL

Java ⇒ AspectJ

C#/VB.Net ⇒ Aspect.NET

C/C++ ⇒ AspectC/Aspect C++

Features Class Example Conclusion

Properties Examples

Aspects

Aspect-Oriented Programming Languages:

Are fully object-oriented

Add the “aspects” construct

Aspects:

Encapsulate cross-cutting concerns that cannot be captured

by traditional objects

Generically applied to multiple objects

No direct modification to the objects themselves

Applied to all the objects in a program, or just a single object

Can add methods, or run code around existing methods

Can implement the methods defined by an interface (instead

of requiring an implementing object to do this)

Features Class Example Conclusion

Properties Examples

www.volantec.biz/Untangle AOP.ppt

Features Class Example Conclusion

Traversing Trees Diagram

Tree Traversal

Options for traversing a tree with varying types of nodes:

“Traditional” OO approach

“Functional” approach

Visitor approach

Aspect oriented approach

Note: Traversing our AST is a cross-cutting concern!

Anything besides Aspect-Oriented Programming is going to require

redundant code, clumsy “hacks” or special patterns that “abuse”

features of object-orientation.

Features Class Example Conclusion

Traversing Trees Diagram

Tree Traversal

Options for traversing a tree with varying types of nodes:

“Traditional” OO approach

“Functional” approach

Visitor approach

Aspect oriented approach

Note: Traversing our AST is a cross-cutting concern!

Anything besides Aspect-Oriented Programming is going to require

redundant code, clumsy “hacks” or special patterns that “abuse”

features of object-orientation.

Features Class Example Conclusion

Traversing Trees Diagram

Tree Traversal (cont.)

Anything besides Aspect-Oriented Programming is going to require

redundant code, clumsy “hacks” or special patterns that “abuse”

features of object-orientation.

Example

The visitor pattern uses (and some would argue abuses) the

polymorphic features of object-oriented languages to reduce the

code that is required to be part of a collection of objects. Every

object still has to have a minimal visit() method, however.

Aspect-Orientation will eliminate the need to ever touch the

original objects. No need for a visit() method!

Features Class Example Conclusion

Traversing Trees Diagram

Visitor Pattern with AOP

Implementing the Visitor Pattern with AspectJ:

Example

aspect VisitAspect {

void IfCommand.acceptVisitor(Visitor v) {

v.visit(this);

Features Class Example Conclusion

Traversing Trees Diagram

Diagram 1

AST

= visit() method

Features Class Example Conclusion

Traversing Trees Diagram

Diagram 2

AST

= visit() method