ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By Ebru Doan
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan
Presentation Outline 1. 2. 3. 4. 5. 6. 7. 8. 9. Current Methods and Languages Separation of Concerns (SOC) Problem: cross-cutting Concepts of Aspect-Oriented Development Aspect Oriented Programming (AOP) Applications: Tracer example Integration Aspects and Components Conclusions References
Current Methods and Languages n n Support abstraction mechanisms for breaking a system down into components Concentrate on finding and composing functional units
Benefits of Good Modularity n Also known as “clean separation of concerns” q q q no scattered code no tangling highly cohesive & loosely coupled
Separation of Concerns - Cohesion n Cohesive component performs only one concern/task
Separation of Concerns - Coupling n n Two components are independent if they do not have interactions Highly coupled components have many dependencies/interactions
Modularity is not always possible. . . n Some concerns don’t localize to objects … their code tends to be orthogonal to the rest of the requirements … and is spread out through many modules
Examples of crosscutting concerns q q q q Synchronization Real-time constraints Error-checking Object interaction constraints Memory management Persistency Security Caching Logging Monitoring Testing Domain specific optimization. . .
Example - Figure Editor - Design
Figure Editor Example –cont’d
Crosscutting Concern - Example
Aspect-oriented development n n n Aspect-oriented development addresses separation of concerns (SOC) Concerns are associated with cross-cutting Cross-cutting concerns are implemented as aspects and are dynamically woven into a program
Motivation for Aspect-Oriented Programming n n Programming paradigm for encapsulating crosscutting concerns into aspects. AOP builds on top of other programming paradigms: object-oriented, procedural or functional. It does not supplant them.
Key Abstractions for Different Programming Paradigms Paradigm Abstraction Modularization Structured programming control flow control structure Procedural programming computations procedure Object-oriented programming data types class/object Aspect-Oriented programming crosscutting concerns aspect
Concepts of AOP (I) n n n Aspect: unit encapsulating a crosscutting concern. Join point: point in the execution of a program where an aspect might intervene. “[. . . ] whenever condition C arises, perform action A” q q q Pointcut: expression of a subset of join points (condition C) Advice: piece of code for action A. Pointcuts and advice encapsulated into aspects.
Concepts of AOP (II) n Weaving
Few Examples of Existing AOP technologies q q q q Aspect. J Hyper. J Aspect. C++ Aspect# Caesar Composition. Filters Aspect. Werkz JBoss-AOP
Most Popular AOP technology n Aspect. J q q q a general purpose AO programming language just as Java is a general-purpose OO language extension to Java
Aspect. J n Five simple steps to create an AOP 1. 2. 3. 4. 5. Define the core/base functionality classes Define the aspect class Define the pointcut Declare the advice Weave & Compile
Tracer Example – Without AOP
Tracer Example – With AOP
Advantages of AOP n n n Improves performance Allows better code reuse Enables better code encapsulation
Componentizing Aspects n n n Representing each aspect as a single reusable component Map the characteristics of a component on aspect Explore the applicability of concepts on aspect
Conclusions n n Crosscutting concerns are typically scattered over several modules and result in tangled code. This reduces the modularity and as such the quality of the software system. AOSD provides explicit abstractions mechanisms to represent these so-called aspects and compose these into programs. Increases the modularity of systems.
References n n n http: //www. aosd. net/ http: //www. eclipse. org/aspectj/ http: //en. wikipedia. org/wiki/Aspectoriented_programming http: //csl. ensm-douai. fr/fakih/phd [Fil 05] “Aspect-Oriented Software Development” by R. Filman et al. , ISBN: 0321219767
- Slides: 25