Aspect-Oriented Software
Development
Dr. Awais Rashid
Computing Department
Lancaster University, UK
© Awais Rashid, 2005.Fundamental to Next
Generation Software
•
“AOSD is vital to our [IBM Software Group’s]
survival”.
Daniel Sabbah, IBM Vice President, speaking at
AOSD Conference, Lancaster University, 2004.
•
AOSD among top ten most promising technologies.
MIT Technology Review
• Being employed in
projects at IBM, Siemens, Boeing,
BEA, Oracle and NASA.
•
DARPA
PCES Programme investing approx.
15 million
USD/year
•
Support of 4.4m Euros to AOSD-Europe by the EC
•
Will be at the Plateau of Productivity in 5-10 years
Outline
• Motivation
• Aspect-Oriented Software
Development
• State-of-the-art in languages, methods
and tools
• Case studies
• Open issues
Need to Tackle Complexity
• Software systems are becoming
increasingly complex
• Estimated 15 million software
professionals worldwide
• Estimated 8000 lines of code per
developer per year
⇒
36 billion lines of code per year
worldwide
• Do the above figures add up?
Complexity Affects Quality
• Intrinsic vs extrinsic complexity
• Affects quality attributes of software
systems
• Evolvability
• Cost-efficiency
• Composability
• Reliability
• Fault tolerance
• Reusability
• Scalability
• Dependability
• Adaptability
• Etc.
Need for Separation of
Concerns
Development requires focusing on one concern
at a time
Outline
• Motivation
• Aspect-Oriented Software
Development
• State-of-the-art in languages, methods
and tools
• Case studies
• Open issues
Aspect-Oriented Software
Development (AOSD)
Distribution Security Data ManagementAOSD tools, techniques and methodology Distribution Security Data Management
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
History and Evolution of
AOSD
Evolution
Time
In the Making InitialBreakthroughExcitement Stabilisation TowardsMaturity
Composition Filters, Adaptive Prog., SOP, Reflection AspectJ @ PARC Hyper/J, UML Ext. AspectJ @ Eclipse, AOSD Conf.
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.
Crosscutting: The Logging
Concern in a Bank Application
class Account { // some attributes
void deposit(int amount) { Logger.log(“Entering Account.deposit( )”); // method code Logger.log(“Leaving Account.deposit( )”); } String holderName( ) { Logger.log(“Entering Account.holderName( )”); // method code Logger.log(“Leaving Account.holderName( )”); // return a string } class Loan { // some attributes void sendReminder( ) { Logger.log(“Entering Loan.sendReminder( )”); // method code Logger.log(“Leaving Loan.sendReminder( )”); } int getBalance( ) { Logger.log(“Entering Loan.getBalance( )”); // method code Logger.log(“Leaving Loan.getBalance( )”); // return an integer }
Tangling and Scattering
Account Loan Customer
Data Classes
ATM Web PC Terminal
User Interface
Persistence
Revisiting the Logging Example
class Account { // some attributes
void deposit(int amount) { Logger.log(“Entering Account.deposit( )”); // method code Logger.log(“Leaving Account.deposit( )”); } String holderName( ) { Logger.log(“Entering Account.holderName( )”); // method code Logger.log(“Leaving Account.holderName( )”); // return a string } class Loan { // some attributes void sendReminder( ) { Logger.log(“Entering Loan.sendReminder( )”); // method code Logger.log(“Leaving Loan.sendReminder( )”); } int getBalance( ) { Logger.log(“Entering Loan.getBalance( )”); // method code Logger.log(“Leaving Loan.getBalance( )”); // return an integer }
Wouldn’t it be Nice if …
class Account {// some attributes
void deposit(int amount) { // method code } String holderName( ) { // method code // return a string } class Loan { // some attributes void sendReminder( ) { // method code } int getBalance( ) { // method code // return an integer } aspect Logger {
when someone calls these methods
before the call {Logger.log(“Entering ” + methodSignature);} after the call {Logger.log(“Leaving ” + methodSignature);} }
Revisiting the Persistence and
Security Example
Account Loan Customer
Data Classes
ATM Web PC Terminal
User Interface
Persistence
Wouldn’t it be Nice if …
Account Loan Customer
Data Classes
ATM Web PC Terminal
User Interface
aspect Persistence
aspect Security
Aspect-Oriented
Programming (AOP)
Class A
Class B
Classes
Aspects
Aspect X Aspect YAspect
Weaver
Composed
Code
Legend
Join Points: Reference points in classes used by aspects for specifying relationships with classes
The Notion of a Join Point
class Account {// some attributes
void deposit(int amount) { // method code } String holderName( ) { // method code // return a string } class Loan { // some attributes void sendReminder( ) { // method code } int getBalance( ) { // method code // return an integer } aspect Tracing {
when someone calls these methods
before the call {Logger.log(“Entering ” + methodSignature);} after the call {Logger.log(“Leaving ” + methodSignature);} }
Type
of
Join Point
Points in this
Specific Join
Program that
we are
Programmer Productivity
(without AOP)
• Typically one class or component per
file
• For a typical release of a software
system, logging or tracing effort
– 15 minutes per file
• 100 files will require 25 person hours
• 1000 files will require 7 person weeks
Source: Adrian Colyer, Gregor Kiczales, Adoption of AOSD, AOSD Conference 2005
Programmer Productivity (with
AOP)
• Typical effort to write a tracing or
logging aspect
– Less than 25 person hours for a simple
one
– Less than 50 person hours for a more
elaborate, properly tested aspect
– Write once, reuse again and again
– Very cost-effective
Source: Adrian Colyer, Gregor Kiczales, Adoption of AOSD, AOSD Conference 2005
Outline
• Motivation
• Aspect-Oriented Software
Development
• State-of-the-art in languages, methods
and tools
• Case studies
• Open issues
Aspect-Oriented Programming
Languages and Frameworks
• AspectJ and AJDT (Eclipse) – IBM
• AspectWerkz and WebLogic – BEA
• JBoss AOP – JBoss Group
• Spring AOP – Spring project
• AspectS – DoCoMo Labs
• CaesarJ – Technical Univ. of Darmstadt
• AspectC – Univ. of British Columbia
• AspectC++ – Univ. of Erlangen-Nuremberg
• A number of other AOP languages, frameworks and
tools listed at: http://aosd.net
Aspect-Oriented Requirements
Analysis and Design
• 15 million software professionals
worldwide
• Only 30% are coders
1
• A significant effort goes into:
– Requirements engineering
– Modelling
– Architecture and design
– Testing and evolution
Better Understanding of the
Problem Domain
• Early Aspects: Aspect-oriented
requirements engineering
– Better understanding of the influence of
crosscutting properties on the problem
– Identify trade-offs early on
– Support decision making amongst stakeholders
– Early aspects drive architectural choices
• A number of UML extensions are already
available for subsequent modelling and
design
Preserving Architectural
Constraints
• Use aspects to declare warnings or
errors on unwanted development
practices
• Example: IBM Software Group
– Aspects are used to flag warnings when
one product uses APIs from another
– Used in a portfolio of 30 products
– 50000 such places flagged!
– Facilitates packaging and deployment
Source: Adrian Colyer, Gregor Kiczales, Adoption of AOSD, AOSD Conference 2005
Outline
• Motivation
• Aspect-Oriented Software
Development
• State-of-the-art in languages, methods
and tools
• Case studies
• Open issues
Enterprise Software: IBM
WebSphere
• Multiple crosscutting concerns
(without
AOSD)
Please refer to Dr. Daniel Sabbah’s keynote at AOSD conference at Lancaster in 2004:
Enterprise Software: IBM
WebSphere
• First Failure Data Capture
(without AOSD)
Please refer to Dr. Daniel Sabbah’s keynote at AOSD conference at Lancaster in 2004:
Enterprise Software: IBM
WebSphere
• First Failure Data Capture
(with AOSD)
Please refer to Dr. Daniel Sabbah’s keynote at AOSD conference at Lancaster in 2004:
Database Evolution: Lancaster
Study
A: Attributes deleted from non-leaf class
B: Introduction of non-leaf class
C: Attributes deleted from leaf class D: Class repositioned 0 5 10 15 20 25 A B C D System X SADES 0 2 4 6 8 10 A B C System X SADES System Y A: Customising routines resulting from additive change
B: Customising routines resulting from
subtractive change
C: Changes to entities upon customisation of instance adaptation approach
Database Aspects in Oracle
TopLink
• Aspects used for exception raising
whenever a developer attempts to write to
the database in a read-only profile
• Aspects used to mark objects as
dirty
for
database updates in a read-mostly profile
• Aspects at the vendor end only
• TopLink developers do not need to know
AOSD
Design Pattern Implementations
• Design patterns are solution templates
for recurring problems during software
development
• Already help to modularise design and
code by guidelines for good structure
• AOSD can further improve the
implementation of several design
patterns
Concern Diffusion over
Components
0 2 4 6 8 10 12Component Decorator Mediator Colleague Handler Memento Originator
N u m b e r of C o m pone nt s Number of Components AO OO AO OO Decorator Pattern Mediator Pattern CoR Pattern Memento Pattern +67% +80% +50% 0% 0% +57% +40% -20% +29% +25% -33%
Before After Before After Before After Before After Before After Before After Before After
+67%
0% +67%
system viewpoint
CDC
Separation of Concerns
0 5 10 15 20 25 30 35Component Decorator Mediator Colleague Handler Memento Originator
N u m b er of Tr a n s itio n Poin ts Num b er of Transition Points AO OO AO OO Mediator Pattern Memento Pattern +78% +25% +85% +22% 0% 0%
Before After Before After Before After Before After Before After Before After Before After +67% 0% +92% CoR Pattern +88% Decorator Pattern +50%+50% 0% +75% 50 CDLO C
Scalability: Introducing New
Elements
0 2 4 6 8 10 12Component Decorator Mediator Colleague Handler Memento Originator
Nu m b e r o f C o m p o n e n ts Number o f Co m p onen ts AO OO AO OO Decorator Pattern Mediator Pattern CoR Pattern Memento Pattern +67% +80% +50% 0% 0% +57% +40% -20% +29% +25% -33%
Before After Before After Before After Before After Before After Before After Before After
+67% 0% +67% 0 5 10 15 20
Component Decorator Mediator Colleague Handler Memento Origin
N u m b er o f O p er at io n s Number o f O p er atio ns AO O AO O Decorator Pattern Mediator Pattern Memento Pattern +75% +88% +71% 0% 0% +67% -46% -+6% +60% -40%
Before After Before After Before After Before After Before After Before After Before +67% -14% -29% CoR Pattern 0 5 10 15 20 25 30 35
Component Decorator Mediator Colleagu
N u m b er of Tra n si ti o n P o in ts Number o f Tra n sition Points Mediator Pattern +78% +25%
Before After Before After Before After Before Af +67%
+88% Decorator Pattern
+50%+50% 0%
+75
Other Interesting Projects
• Boeing: Autopilot software product lines
• Siemens: Software product lines and
model-driven development
• New Aspects of Software: Modularising
security policies
• Near Infinity: Auditing in Intelliprints
• TU Darmstadt and TU Berlin: ToppRax
project (evaluation in SMEs)
• Lancaster University: Infolab21 Knowledge
Business Centre (Planned seminars for
Outline
• Motivation
• Aspect-Oriented Software
Development
• State-of-the-art in languages, methods
and tools
• Case studies
• Open issues
Open Issues for AOSD
• Need for more research into models for
early aspects: aspect-oriented requirements
engineering and architecture design
• Need for more research into aspect
mapping and traceability
• Need for effective testing and validation
techniques
• Need for more application studies
Open Issues for AOSD
• Need for AOSD processes
– Adaptation of existing processes to
incorporate AOSD
• Need for more empirical studies
• Need for an
Aspect-Oriented Software
Engineering