introduction to aosd awais rashid, steffen zschaler © awais rashid, steffen zschaler, 2009

24
Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Upload: rashad-dunlow

Post on 14-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Introduction to AOSD

Awais Rashid, Steffen Zschaler

© Awais Rashid, Steffen Zschaler, 2009

Page 2: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Why Aspect-Oriented Software Development (AOSD)?

• Software becoming increasingly large, complex and distributed

• Requires effective separation of concerns– Improve quality attributes

• Evolvability• Cost-efficiency• Composability• Reliability• Fault tolerance

• Reusability• Scalability• Dependability• Adaptability• Etc.

Page 3: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Need for Separation of Concerns

Development requires focusingon one concern

at a time

Large … complex … distributed software systems

Page 4: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

4

Separation of Concerns

E. Dijkstra, A Discipline of Programming, Prentice Hall, 1976, pp. 210

Edsger Dijkstra 1930-2002

Page 5: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

The Problem of Crosscutting Concerns

• Broadly-scoped concerns– Distribution, security, real-time constraints,

etc.– Crosscutting in nature– Severely constrain quality attributes and

separation of concerns

Page 6: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

6

[logging in org.apache.tomcat]

Crosscutting Concerns Affect Modularisation

Bad modularisation

Good modularisation

[XML parsing in org.apache.tomcat]

Page 7: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

7

Resulting Problems• Scattering

– The specification of one property is not encapsulated in a single module

Tangling Each module contains descriptions

of several properties or different functionalities

Page 8: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Aspect-Oriented Software Development (AOSD)

Distribution

Security

DataManagement

AOSD tools, techniquesand

methodology

Distribution

Security

DataManagement

Page 9: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

A Definition of AOSD

• AOSD: systematic identification, modularisation, representation and composition of crosscutting concerns [1]

[1] Rashid, A., Moreira, A., Araujo, J. “Modularisation and Composition of Aspectual Requirements”, Proceedings of 2nd International Conference on Aspect-Oriented Software Development, ACM, 2003.

Page 10: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Potential Benefits of AOSD

• Improved ability to reason about problem domain and corresponding solution

• Reduction in application code size, development costs and maintenance time

• Improved code reuse• Requirements, architecture and design-level

reuse• Improved ability to engineer product lines• Context-sensitive application adaptation• Improved modelling methods

Page 11: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

History and Evolution of AOSDEvolution

TimeIn theMaking

InitialBreakthrough

Excitement Stabilisation TowardsMaturity

CompositionFilters,AdaptiveProg., SOP,Reflection

AspectJ@ PARC

Hyper/J,UML Ext.

AspectJ@ Eclipse,AOSDConf.

More expressive Langs.,Early Aspects, Middleware, Databases, Industrial Applications,Transactions on AOSD

“AOSD is vital to our [IBM Software Group’s] survival”. Daniel Sabbah, IBM Vice President, speaking at AOSD Conference, Lancaster University, 2004.

Page 12: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Crosscutting: The Tracing Concern

class A { // some attributes void m1( ) {

System.out.println(“Entering A.m1( )”);// method codeSystem.out.println(“Leaving A.m1( )”);

}

String m2( ) {System.out.println(“Entering A.m2( )”);// method codeSystem.out.println(“Leaving A.m2( )”);// return a string

}

class B { // some attributes void m2( ) {

System.out.println(“Entering B.m2( )”);

// method codeSystem.out.println(“Leaving

B.m2( )”);}

int m3( ) {System.out.println(“Entering

B.m3( )”);// method codeSystem.out.println(“Leaving

B.m3( )”);// return an integer

}

Page 13: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Tangling and Scattering

Account CustomerLoan

Data Classes

ATM PC TerminalWeb

User Interface

PersistencePrimary Functionality Security

Page 14: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Crosscutting: Links Among Meta-Objects (1)

• Links among meta-objects (e.g., class, attribute, method definitions): traditionally information about links is embedded within them

Collection of references tosubclassmeta-objects

Collection of references tosuperclassmeta-objects

Meta-class Class

Page 15: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Crosscutting: Links Among Meta-Objects (2)

PersonSuperclasses

TutorSubclasses Principal

PersonSuperclasses

Tutor

Person

Principal

Introduce as non-leaf node

Staff

Sub-classes

Super-classes

Crosscutting

Page 16: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Revisiting the Tracing Exampleclass A { // some attributes void m1( ) {

System.out.println(“Entering A.m1( )”);// method codeSystem.out.println(“Leaving A.m1( )”);

}

String m2( ) {System.out.println(“Entering A.m2( )”);// method codeSystem.out.println(“Leaving A.m2( )”);// return a string

}

class B { // some attributes void m2( ) {

System.out.println(“Entering B.m2( )”);

// method codeSystem.out.println(“Leaving

B.m2( )”);}

int m3( ) {System.out.println(“Entering

B.m3( )”);// method codeSystem.out.println(“Leaving

B.m3( )”);// return an integer

}

Page 17: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Wouldn’t it be Nice if …class A { // some attributes void m1( ) {

// method code}

String m2( ) {// method code// return a string

}

class B { // some attributes void m2( ) {

// method code}

int m3( ) {// method code// return an integer

}

aspect Tracing {

when someone calls these methods

before the call {System.out.println(“Entering ” + methodSignature);}

after the call {System.out.println(“Leaving ” + methodSignature);}}

Page 18: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Revisiting the Bank Example

Account CustomerLoan

Data Classes

ATM PC TerminalWeb

User Interface

PersistencePrimary Functionality Security

Page 19: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Wouldn’t it be Nice if …

Account CustomerLoan

Data Classes

ATM PC TerminalWeb

User Interface

aspect Persistence

aspect Security

Page 20: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Revisiting the Links Example

PersonSuperclasses

TutorSubclasses Principal

PersonSuperclasses

Tutor

Person

Principal

Introduce as non-leaf node

Staff

Sub-classes

Super-classes

Crosscutting

Page 21: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Wouldn’t it be Nice if …

Tutor

Person

Principal

Introduce as non-leaf node

Staff

aspect super/subclassrelationships

Page 22: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Aspect-Oriented Programming (AOP): The AspectJ Approach

Class A Class B

Classes

Aspects

Aspect X Aspect Y

AspectWeaver

ComposedCode

Legend

Join Points: Reference points in classes used by aspects for specifying relationships with classes

Class Aspect

Page 23: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

The Notion of a Join Pointclass A { // some attributes void m1( ) {

// method code}

String m2( ) {// method code// return a string

}

class B { // some attributes void m2( ) {

// method code}

int m3( ) {// method code// return an integer

}

aspect Tracing {

when someone calls these methods

before the call {System.out.println(“Entering ” + methodSignature);}

after the call {System.out.println(“Leaving ” + methodSignature);}}

Type of Join Point

Specific Join Points in this Program that

we are Interested in

Page 24: Introduction to AOSD Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler, 2009

Discussion Points

• Why not rely on inheritance?

• Why not rely on design patterns?