ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

25
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    224
  • download

    0

Transcript of ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Page 1: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

ASPECT ORIENTEDSOFTWARE

DEVELOPMENT

Prepared By: Ebru Doğan

Page 2: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Presentation Outline

1. Current Methods and Languages2. Separation of Concerns (SOC)3. Problem: cross-cutting4. Concepts of Aspect-Oriented Development5. Aspect Oriented Programming (AOP)6. Applications: Tracer example7. Integration Aspects and Components8. Conclusions9. References

Page 3: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Current Methods and Languages Support abstraction mechanisms for breaking

a system down into components Concentrate on finding and composing

functional units

Page 4: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Benefits of Good Modularity

Also known as “clean separation of concerns”

no scattered code no tangling highly cohesive & loosely coupled

Page 5: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Separation of Concerns - Cohesion Cohesive component performs only one

concern/task

Page 6: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Separation of Concerns - Coupling Two components are independent if they do not

have interactions Highly coupled components have many

dependencies/interactions

Page 7: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Modularity is not always possible...

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

Page 8: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Examples of crosscutting concerns

Synchronization Real-time constraints Error-checking Object interaction constraints Memory management Persistency Security Caching Logging Monitoring Testing Domain specific optimization ...

Page 9: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Example - Figure Editor - Design

Page 10: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Figure Editor Example –cont’d

Page 11: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Crosscutting Concern - Example

Page 12: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Aspect-oriented development 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

Page 13: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Motivation for Aspect-Oriented Programming 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.

Page 14: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Key Abstractions for Different Programming ParadigmsParadigm 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

Page 15: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Concepts of AOP (I)

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”

Pointcut:expression of a subset of join points (condition C) Advice: piece of code for action A. Pointcuts and advice encapsulated into aspects.

Page 16: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Concepts of AOP (II)

Weaving

Page 17: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Few Examples of Existing AOP technologies

AspectJ HyperJ AspectC++ Aspect# Caesar CompositionFilters AspectWerkz JBoss-AOP

Page 18: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Most Popular AOP technology AspectJ

a general purpose AO programming language just as Java is a general-purpose OO language extension to Java

Page 19: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

AspectJ

Five simple steps to create an AOP1. Define the core/base functionality classes

2. Define the aspect class

3. Define the pointcut

4. Declare the advice

5. Weave & Compile

Page 20: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Tracer Example – Without AOP

Page 21: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Tracer Example – With AOP

Page 22: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Advantages of AOP

Improves performance Allows better code reuse Enables better code encapsulation

Page 23: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Componentizing Aspects

Representing each aspect as a single reusable component

Map the characteristics of a component on aspect

Explore the applicability of concepts on aspect

Page 24: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

Conclusions

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.

Page 25: ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.

References

http://www.aosd.net/ http://www.eclipse.org/aspectj/ http://en.wikipedia.org/wiki/Aspect-

oriented_programming http://csl.ensm-douai.fr/fakih/phd [Fil05] “Aspect-Oriented Software

Development” by R.Filman et al., ISBN: 0321219767