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
Source: Grady Booch, Keynote Speech, AOSD Conference 2005 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 Large complex distributed software systems 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 Management AOSD 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
AOSD is vital to our [IBM Software Group s] survival. Evolution History and Evolution of Daniel Sabbah, IBM Vice President, speaking at AOSD Conference, Lancaster University, 2004. AOSD More expressive Langs., Early Aspects, Middleware, Databases, Industrial Applications, Transactions on AOSD Composition Filters, Adaptive Prog., SOP, Reflection AspectJ @ PARC Hyper/J, UML Ext. AspectJ @ Eclipse, AOSD Conf. In the Initial Excitement Stabilisation Towards Time
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 Primary Functionality Persistence Security Data Classes Account Loan Customer User Interface ATM Web PC Terminal
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 Data Classes Primary Functionality Persistence Security Account Loan Customer User Interface ATM Web PC Terminal
Wouldn t it be Nice if Data Classes Account aspect Persistence Loan aspect Security Customer User Interface ATM Web PC Terminal
Aspect-Oriented Programming (AOP) Classes Class A Class B Aspect Weaver Composed Code Aspect X Aspects Aspect Y Legend Class Aspect 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 } Type of Join Point String holdername( ) { // method code // return a string } aspect Tracing { when someone calls these methods class Loan { // some attributes void sendreminder( ) { // method code } Specific Join Points in this Program that we are Interested in int getbalance( ) { // method code // return an integer } before the call {Logger.log( Entering + methodsignature);} after the call {Logger.log( Leaving + methodsignature);}
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,
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,
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 1 Source: Grady Booch, Keynote Speech, AOSD Conference 2005
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,
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: http://aosd.net/2004/archive/aosd-frompromisetoreality.ppt
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: http://aosd.net/2004/archive/aosd-frompromisetoreality.ppt
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: http://aosd.net/2004/archive/aosd-frompromisetoreality.ppt
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 25 20 15 10 5 0 A B C D System X SADES A: Customising routines resulting from additive change B: Customising routines resulting from subtractive change C: Changes to entities upon customisation of instance adaptation approach 10 8 6 4 2 0 A B C System X SADES System Y
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 system viewpoint Components 12 Decorator Pattern Mediator Pattern CoR Pattern Memento Pattern CDC Number of of Components 10 8 6 4 2 +67% +80% +50% +25% 0% +67% 0% +57% +67% +29% AO OO +40% -20% 0% -33% 0 Before After Before After Before After Before After Before After Before After Before After Component Decorator Mediator Colleague Handler Memento Originator
Separation of Concerns 35 +88% Decorator Pattern Mediator Pattern 50 CoR +92% Pattern Memento Pattern CDLOC Number Number of of Transition Transition Points Points 30 25 20 15 10 5 +78% +75% +67% +25% +50%+50% 0% +85% 0% 0% AO OO +22% 0% 0 Before After Before After Before After Before After Before After Before After Before After Component Decorator Mediator Colleague Handler Memento Originator
Scalability: Introducing New Elements Number of of Components 12 10 8 6 4 2 +67% Decorator Pattern +80% +50% +25% Number of Operations 0% 20 15 Mediator Decorator CoR Pattern Pattern Pattern +67% 10 5 +75% +88% 0% +57% +67% +60% Mediator +88% Memento Decorator CoR -29% Pattern Pattern Pattern Pattern +29% AO OO +40% -20% +71% Number Number of of Transition Transition Points Points 0% 35 30 25 20 15 0% +67% 10 5 +78% -33% 0% +67% -46% +50%+50% 0% Mediator Memen Pattern +6% -14% +67% + +25% -4 0 0 0 Before After Before After Before After Before Before After After Before Before After AfterBefore Before After After Before After Before Before After After Before Before After AfterBefore Before After AfterBefore Component Decorator MediatorComponent ColleagueDecorator Handler Mediator Memento Component Colleague Originator Decorator Handler Mediator Memento Colle O
Other Interesting Projects Boeing: Autopilot software product lines Siemens: Software product lines and modeldriven 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 SMEs)
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 In research labs and in industry
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