Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Idaho National Engineering and Environmental Laboratory What is a Framework? Web Service? Why do you need them? Wayne Simpson November.
Programming Paradigms and languages
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development.
Aspect Oriented Programming - AspectJ Radhika Rajput.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
Objects First with Java A Practical Introduction using BlueJ
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
1 Objectives To introduces the concept of software Design. To introduce the concept of Object- Oriented Design (OOD). To Define various aspects about object.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
C++ fundamentals.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
What Is a Factory Pattern?.  Factories are classes that create or construct something.  In the case of object-oriented code languages, factories construct.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Introduction to AOP.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
BCS 2143 Introduction to Object Oriented and Software Development.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
1 N Degrees of Separation: Multi-Dimensional Separation of Concern (MDSOC) HyperJ: language and concepts of general concern combination.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Programming Paradigms
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Introduction Better Faster Cheaper (pick any two) On-going issue that continues to motivate research in software engineering Applications: –continue to.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Click to edit Master text styles JavaMOP Hamid Reza Niroomand A presentation to Dr. Babamir.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Introduction to Yan Cui Aspect Oriented Programming by
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
R R R A Brief Introduction to Aspect-Oriented Programming.
Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS.
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Fall 2013 Chapter 10 Thinking.
Distributed Shared Memory
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
About the Presentations
PL/SQL Scripting in Oracle:
Aspect-Oriented Programming
JAsCo an Aspect-Oriented approach tailored for
Structuring Adaptive Applications using AspectJ and AOM
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
John D. McGregor Module 6 Session 1 More Design
AspectAda Aspect-Oriented Programming for Ada95
Classes, Objects and Methods
Function-oriented Design
Presentation transcript:

Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar

Overview Motivation for Aspect Oriented Programming What is Aspect Oriented Programming? How Does Aspect Oriented Programming Work? Case Study

Motivation for Aspect Oriented Programming First Computer Programs Consisted of cryptic binary strings Consisted of cryptic binary strings

Motivation for Aspect Oriented Programming Next Generation “Higher-Level” Assembly “Higher-Level” Assembly

Motivation for Aspect Oriented Programming 1957: Birth of Real “High-Level” Language IBM’s Fortran IBM’s Fortran Division created between a computer’s hardware and the coupling that hardware imposed upon the software. Subprograms, or subroutines Modular code blocks allowed decomposition into smaller pieces Modular code blocks allowed decomposition into smaller pieces Increased reusability and maintainability of code Increased reusability and maintainability of code

Motivation for Aspect Oriented Programming Late 1960s: Object Oriented Paradigm Collection of related data and operations useful to that data Collection of related data and operations useful to that data Paved way for Modern C++, Java, C#, etc. Paved way for Modern C++, Java, C#, etc.

Motivation for Aspect Oriented Programming Problems with OO Although specific groups of data and operations are cohesively grouped together, other secondary operations still need to be duplicated across these objects. Although specific groups of data and operations are cohesively grouped together, other secondary operations still need to be duplicated across these objects. High-level, system-wide requirements High-level, system-wide requirements Application logging Security requirements Other Policy Layer Requirements

Motivation for Aspect Oriented Programming General Application-wide requirements still need to be supported via these objects but are not explicitly encapsulated in one single object type

Motivation for Aspect Oriented Programming Assume following scenario Employee record system Employee record system Collection of employee related objects Each object has cohesive set of operations that perform necessary manipulations on the data contained within that object

Motivation for Aspect Oriented Programming Employee Record System Now imagine that the system is extended to support logging each employee change to a logging database. Now imagine that the system is extended to support logging each employee change to a logging database.

Motivation for Aspect Oriented Programming OO Approach Developers will have to Dive inside the employee objects Dive inside the employee objects Add additional operations to support logging Wading through existing code and finding the exact locations to insert logging operations can be a time-consuming, tedious, and error-prone process which can lead to software instability and security flaws. Writing to a database, or ensuring sufficient privileges are obtained does not coherently fit with what employee objects represent – BAD COHESION (Dr. Rowe = Angry)

What Is Aspect Oriented Programming? Solution = Aspect Oriented Approach We want to add new functionality in a single location and simply specify that this new functionality is to be invoked when certain conditions arise. Added functionality is achieved without wading through existing code and appending duplicate functionality across existing operations.

What Is Aspect Oriented Programming? Employee Record System We will be able to create one central collection of operations responsible for logging to a database We will be able to create one central collection of operations responsible for logging to a database Specify that a database write shall be invoked when an employee object is modified. Specify that a database write shall be invoked when an employee object is modified.

How Does Aspect Oriented Programming Work? Cross-Cutting Concern: Some aspects of implementation, such as logging, error handling, standards enforcement, and policy-layer modification are difficult to implement in a modular way. The result is that code is tangled across a system; this leads to quality, productivity, and maintenance issues. These issues are cross-cutting concerns

How Does Aspect Oriented Programming Work? Advice: This is the additional code that one wants to apply to an existing model to add support for features such as logging, error handling, standards enforcement, and policy-layer modification

How Does Aspect Oriented Programming Work? Point Cut: This is the term given to the point of execution in the application at which a cross- cutting concern needs to be applied. In our example, a point-cut is reached when a thread of execution within the employee record system enters a method responsible for modifying an employee; a second point-cut is reached when that thread of execution leaves the method responsible for modifying an employee

How Does Aspect Oriented Programming Work? Aspect: The combination of the point-cut and the advice is termed an aspect. In our example, we add a logging aspect to our employee record system by defining a point-cut and giving the correct advice to execute when that point-cut is reached + =

aspect vs class aspect specific data and operations are “static” aspect is a singleton pointcut declaration advice

How Does Aspect Oriented Programming Work? Point-cut named “LogEmployeeChange” Specify specific points where employee object changed Specify specific points where employee object changed Deals only with objects of type “Employee” (line 13) Deals only with objects of type “Employee” (line 13) Deals specifically with 4 methods contained within the “Employee” class (lines 14-17) Deals specifically with 4 methods contained within the “Employee” class (lines 14-17) Line 14 explicitly says, “for any ‘public’ method of class ‘Employee’ with any type of return parameter (‘*’), a name of ‘setName’, and a parameter set of anything (‘..’), execute the corresponding Advice Line 14 explicitly says, “for any ‘public’ method of class ‘Employee’ with any type of return parameter (‘*’), a name of ‘setName’, and a parameter set of anything (‘..’), execute the corresponding Advice Note: use of wildcards allow the aspect programmer to include a large grouping of functions in a single line. Note: use of wildcards allow the aspect programmer to include a large grouping of functions in a single line.

How Does Aspect Oriented Programming Work? before Advice Line 19 says, “Since my associated point-cut has been triggered, execute the code in my block before executing the method which triggered the point-cut.” Line 19 says, “Since my associated point-cut has been triggered, execute the code in my block before executing the method which triggered the point-cut.” The actual instance of the Employee class which will be modified is passed into the before Advice as “Employee e”; the advice can modify Employee e. The actual instance of the Employee class which will be modified is passed into the before Advice as “Employee e”; the advice can modify Employee e.

How Does Aspect Oriented Programming Work? After executing before Advice, the method which triggered the point-cut is executed; this method could be “setName”, “setAddress”, etcetera. Once execution returns from this method, the after Advice is considered.

Case Study: Apache Tomcat Tomcat: open-source implementation of Java Servlet and JavaServer Pages developed at the Apache Software Foundation. Object-Oriented Object-Oriented

Case Study: Apache Tomcat Red Shows encapsulated XML Parser in Tomcat

Case Study: Apache Tomcat Red Shows encapsulated URL Pattern Matching in Tomcat

Case Study: Apache Tomcat Red Shows Tomcat Logging A single logging aspect can replace this tangle Increase Cohesion Increase Cohesion Decrease Coupling Decrease Coupling Increase Maintainability Increase Maintainability No duplicated logging code across multiple classes No duplicated logging code across multiple classes

Summary AspectJ and Aspect-Oriented Programming represent a way to cleanly modularize high-level requirements which span across the scope of many different classes and operations. Using AspectJ can greatly alleviate issues related to logging, monitoring, application-spanning requirements, and many other issues that commonly cause headaches for even well- designed Object-Oriented systems