KEMBAR78
Aspect Oriented Software Development | PPT
Aspect-Oriented Software Development (AOSD) Jignesh Patel Jignesh.Patel [AT] umkc [DOT] edu
Background Evolution of software programming methodology Machine-Level coding Structured Programming Object-Oriented Programming Programming methodology defines the way we communicate with machines. presents new ways to decompose problems –  Machine-code, machine-independent code, procedures, classes and so on… provides a more natural mapping of system requirements to programming constructs.
Background Object-Oriented Programming Set of collaborating objects. Hide implementation details in Classes. Common behavior for related concepts using Polymorphism Favorite Choice for developing most new software projects. Why? Allowed us to deal with complex software projects. But  OOP  is not the  panacea
Background Limitations of Object-Oriented Programming Requirements do not decompose into behavior centered on a single locus. difficulty localizing concerns involving global constraints and pandemic behaviors, appropriately segregating concerns, and applying domain-specific knowledge.  Post-object programming (POP) mechanisms that look to  Increase the expressiveness of the OO paradigm  are a fertile arena for current research.  Examples of POP technologies include  domain-specific languages, generative programming, generic programming, constraint languages, reflection and metaprogramming, feature-oriented development.
History Aspect-Oriented Programming (AOP) Latest entrant in programming methodologies Represents one facet of Aspect-Oriented Software Development (AOSD) Attributed to Greger Kiczales et al.,  University of British Columbia Works on software modularity research Leader in the development and implementation of AOP at Xerox Palo Alto Research Center (PARC) from 1984 - 1999
Why AOP? – Example You are responsible for maintaining large software system that managed payroll and personnel functions for your organization. What if management issued a new requirement ? “ create a log of all changes to an employee’s data” This would include changes in – Payroll  Number of deductions Raises Employee’s personal data 100s of many other information associated with employee What would you do?
Aspect-Oriented Programming Computer systems are better programmed by separately specifying the various “concerns” Concerns : properties or areas of interests High-level  – security, QoS Low-level  – caching, buffering Functional  – features, business rules Non Functional  (systemic) – synchronization, transaction management.
System = set of “concerns” A typical system may consist of several kind of concerns including – Business logic Performance Data persistence Logging and Debugging Authentication Security Multi-threaded safety Error-checking and so on…
Concerning “Concerns” Why they are difficult to program? Some concerns are neatly localized within specific structural piece, Others tend to scatter and cross multiple elements. aka  “Crosscutting Concerns” Problems  Not every concern fits into a component:  crosscutting Two issues: Implementation for authentication, contract checking and logging is not localized. Code spans over many methods of potentially many classes and packages.  aka  Code Scattering Implementation of someOperation() does much more than performing some core functionality. It contains code for more than one concerns. aka  Code tangling
Crosscutting Concerns Implementation Modules becomes mess when we code these concerns Performance
Aspect-Oriented Programming AOP is designed to handle crosscutting concerns by providing a mechanism known as  aspect   Aspects Express these concerns and automatically incorporates them into a system.  Enhances the ability to express separation of these concerns. Leads to well-designed, maintainable software system. AOP doesn’t  replace  existing programming paradigms and languages.  Instead it works  with  them to improve their expressiveness and utility.
Aspect-Oriented Programming  components  and  aspect  descriptions weaver (compile-time) Source Code (tangled code)
AOSD Tools  abc  is a full implementation of the AspectJ language, with an emphasis on extensibility and optimisations.  Aspect#  is a free AOP framework for .NET.  AspectC++  is an aspect-oriented extension to the C++ programming language.  AspectDNG  is a .NET multi-language aspect weaver.  AspectJ  is a seamless aspect-oriented extension to Java that enables the modular implementation of a wide range of crosscutting concerns.  AspectWerkz  is a dynamic, lightweight and high-performant AOP/AOSD framework for Java.  AspectXML  is an attempt to sound out, brainstorm, and generally try out the aspect oriented approach in relation to XML.  JAC  is a Java framework for aspect-oriented distributed programming.  JBoss-AOP  is the Java AOP architecture used for the JBOSS application server.  LOOM.NET  is a static aspect weaver that operates on binary .NET assemblies. The RAPIER-LOOM.NET library is a dynamic aspect weaver.  Nanning  is an Aspect Oriented Framework for Java based on dynamic proxies and aspects implemented as ordinary Java-classes.  Spring 's approach to AOP differs from that of most other AOP frameworks. The aim is not to provide the most complete AOP implementation (although Spring AOP is quite capable); it is rather to provide a close integration between AOP implementation and Spring IoC to help solve common problems in enterprise applications.  XWeaver  is an extensible, customizable and minimally intrusive aspect weaver for C/C++ — it generates source code which differs as little as possible from the base code (preserves layout and comments).
Logging example in  AspectJ Three steps to program using AspectJ Identify places in the code where we want to insert the logging code. This is called  defining  join points  in AspectJ.  Write the logging code.  Compile the new code and integrate it into the system.
Logging Example – Step1 Define the join points A  join point  is a well-defined point in the code at which our concerns crosscut the application.  In AspectJ, we define join points by grouping them into  pointcuts .
Logging Example – Step2 Write the Logging code In AspectJ, we define  what  to do by grouping them into  advice .  three kinds of advice :  before ,  after  and  around
Logging Example – Step3 Compile and Test This code runs just fine without any AOP implementation   Output:
Logging Example – Step3 Compile and Test incorporate our aspect into the system, we add the aspect source code to the project and build with the AspectJ compiler,  ajc   The compiler takes each aspect  creates class files that contain the advice code.  calls to the appropriate methods in these class files are  woven  into the original application code   In AspectJ this is done at Java  bytecode  level Output: Lets play “ starwars ”
Recap of AOP Separation of concerns   (monitoring, synchronisation, debugging, security, etc.) Where What MyAspect In MyProgram Before process  { display data print “before process” } MyProgram collect data process data display result Weaver Synchronisation Aspect Business code Classes Monitor Aspect Tangled Classes, Crosscutting Concerns synchronisation monitoring MyProgram collect data display data print “before process” process data display result
What does all these mean? AOP has many potential benefits provides a way of specifying and encapsulating cross-cutting concerns in a system. allow us to do a better job of maintaining systems as they evolve let us add new features, in the form of concerns, to existing systems in an organized manner. improvements in expressiveness and structure helps us to keep systems running longer, without incurring the expense of a complete rewrite. a great addition to quality professionals’ toolboxes. Ability to test application code automatically without disturbing the code.
AOP – a prism analogy
Early Aspects & AOSD research Early Aspects Separating aspects and concerns at early stages of software development life cycle.  Main AOSD research interests: Semantics of AO Languages and Formal Methods (Composition, Join point, Pointcuts, Advices, Weaving) Aspects in Early Life cycle Steps Design of concerns Dynamic Aspects and Infrastructure Software
Among the Most Popular downloads ©2005 ACM  0001-0782/05/0400  $5.00 Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.  Communications of the ACM, Volume 48, No 4 (Apr 2005), Pages 33-34
Conclusion AOP Modularized implementation of crosscutting concerns   Easier-to-evolve systems   Late binding of design decisions   More code reuse   If software system comprises of crosscutting concerns consider learning more about AOP
Latest AOSD conference (2005, March 22-26, Chicago, Illinois) Using AspectJ to Build a Product Line for Mobile Devices Developing Embedded Software Product Lines with AspectC++ Aspect-Oriented Programming with Caesar Developing Dynamic and Adaptable Applications with CAM/DAOP: A Virtual Office Application PROSE - A middleware platform for dynamic adaptation Microsoft Phoenix: A Framework for Software Analysis and Optimization
References Many tools, papers, and other resources related to aspect-oriented software development here:  http:// aosd.net   Read more about Xerox's AspectJ, a free AOP implementation for Java:  http:// aspectj.org   Ramnivas Laddad's "XML APIs for Databases" ( JavaWorld,  January 2000) explains how to blend the power of XML and databases using custom SAX and DOM APIs :  http://www.javaworld.com/javaworld/jw-01-2000/jw-01-dbxml.html  Communications of the ACM , October 2001, has many articles on AOSD  Past AOSD Conferences   http://aosd.net/conference Grundy, J. “Aspect-oriented Requirements Engineering for Component-based Software Systems”, 4th IEEE International Symposium on Requirements Engineering, IEEE Computer Society, Limerick, Ireland, 1999, pp. 84-91  IBM Research. MDSOC: Software Engineering Using Hyperspaces,  http:// www.research.ibm.com /hyperspace/ Moreira, A., Araújo, J., Brito, I. “Crosscutting Quality Attributes for Requirements Engineering”, 14th International Conference on Software Engineering and Knowledge Engineering (SEKE 2002), ACM Press, Italy, July 2002. Rashid, A., Sawyer, P., Moreira, A. and Araújo, J. “Early Aspects: a Model for Aspect-Oriented Requirements Engineering”, IEEE Joint Conference Workshop on “Aspect-oriented Modeling with UML”.  http://lglwww.epfl.ch/workshops/aosd-uml/ Workshop on “Early Aspects: Aspect-Oriented Requirements Engineering and Architecture Design”.  http://trese.cs.utwente.nl/AOSD-EarlyAspectsWS/

Aspect Oriented Software Development

  • 1.
    Aspect-Oriented Software Development(AOSD) Jignesh Patel Jignesh.Patel [AT] umkc [DOT] edu
  • 2.
    Background Evolution ofsoftware programming methodology Machine-Level coding Structured Programming Object-Oriented Programming Programming methodology defines the way we communicate with machines. presents new ways to decompose problems – Machine-code, machine-independent code, procedures, classes and so on… provides a more natural mapping of system requirements to programming constructs.
  • 3.
    Background Object-Oriented ProgrammingSet of collaborating objects. Hide implementation details in Classes. Common behavior for related concepts using Polymorphism Favorite Choice for developing most new software projects. Why? Allowed us to deal with complex software projects. But OOP is not the panacea
  • 4.
    Background Limitations ofObject-Oriented Programming Requirements do not decompose into behavior centered on a single locus. difficulty localizing concerns involving global constraints and pandemic behaviors, appropriately segregating concerns, and applying domain-specific knowledge. Post-object programming (POP) mechanisms that look to Increase the expressiveness of the OO paradigm are a fertile arena for current research. Examples of POP technologies include domain-specific languages, generative programming, generic programming, constraint languages, reflection and metaprogramming, feature-oriented development.
  • 5.
    History Aspect-Oriented Programming(AOP) Latest entrant in programming methodologies Represents one facet of Aspect-Oriented Software Development (AOSD) Attributed to Greger Kiczales et al., University of British Columbia Works on software modularity research Leader in the development and implementation of AOP at Xerox Palo Alto Research Center (PARC) from 1984 - 1999
  • 6.
    Why AOP? –Example You are responsible for maintaining large software system that managed payroll and personnel functions for your organization. What if management issued a new requirement ? “ create a log of all changes to an employee’s data” This would include changes in – Payroll Number of deductions Raises Employee’s personal data 100s of many other information associated with employee What would you do?
  • 7.
    Aspect-Oriented Programming Computersystems are better programmed by separately specifying the various “concerns” Concerns : properties or areas of interests High-level – security, QoS Low-level – caching, buffering Functional – features, business rules Non Functional (systemic) – synchronization, transaction management.
  • 8.
    System = setof “concerns” A typical system may consist of several kind of concerns including – Business logic Performance Data persistence Logging and Debugging Authentication Security Multi-threaded safety Error-checking and so on…
  • 9.
    Concerning “Concerns” Whythey are difficult to program? Some concerns are neatly localized within specific structural piece, Others tend to scatter and cross multiple elements. aka “Crosscutting Concerns” Problems Not every concern fits into a component: crosscutting Two issues: Implementation for authentication, contract checking and logging is not localized. Code spans over many methods of potentially many classes and packages. aka Code Scattering Implementation of someOperation() does much more than performing some core functionality. It contains code for more than one concerns. aka Code tangling
  • 10.
    Crosscutting Concerns ImplementationModules becomes mess when we code these concerns Performance
  • 11.
    Aspect-Oriented Programming AOPis designed to handle crosscutting concerns by providing a mechanism known as aspect Aspects Express these concerns and automatically incorporates them into a system. Enhances the ability to express separation of these concerns. Leads to well-designed, maintainable software system. AOP doesn’t replace existing programming paradigms and languages. Instead it works with them to improve their expressiveness and utility.
  • 12.
    Aspect-Oriented Programming components and aspect descriptions weaver (compile-time) Source Code (tangled code)
  • 13.
    AOSD Tools abc is a full implementation of the AspectJ language, with an emphasis on extensibility and optimisations. Aspect# is a free AOP framework for .NET. AspectC++ is an aspect-oriented extension to the C++ programming language. AspectDNG is a .NET multi-language aspect weaver. AspectJ is a seamless aspect-oriented extension to Java that enables the modular implementation of a wide range of crosscutting concerns. AspectWerkz is a dynamic, lightweight and high-performant AOP/AOSD framework for Java. AspectXML is an attempt to sound out, brainstorm, and generally try out the aspect oriented approach in relation to XML. JAC is a Java framework for aspect-oriented distributed programming. JBoss-AOP is the Java AOP architecture used for the JBOSS application server. LOOM.NET is a static aspect weaver that operates on binary .NET assemblies. The RAPIER-LOOM.NET library is a dynamic aspect weaver. Nanning is an Aspect Oriented Framework for Java based on dynamic proxies and aspects implemented as ordinary Java-classes. Spring 's approach to AOP differs from that of most other AOP frameworks. The aim is not to provide the most complete AOP implementation (although Spring AOP is quite capable); it is rather to provide a close integration between AOP implementation and Spring IoC to help solve common problems in enterprise applications. XWeaver is an extensible, customizable and minimally intrusive aspect weaver for C/C++ — it generates source code which differs as little as possible from the base code (preserves layout and comments).
  • 14.
    Logging example in AspectJ Three steps to program using AspectJ Identify places in the code where we want to insert the logging code. This is called defining join points in AspectJ. Write the logging code. Compile the new code and integrate it into the system.
  • 15.
    Logging Example –Step1 Define the join points A join point is a well-defined point in the code at which our concerns crosscut the application. In AspectJ, we define join points by grouping them into pointcuts .
  • 16.
    Logging Example –Step2 Write the Logging code In AspectJ, we define what to do by grouping them into advice . three kinds of advice : before , after and around
  • 17.
    Logging Example –Step3 Compile and Test This code runs just fine without any AOP implementation Output:
  • 18.
    Logging Example –Step3 Compile and Test incorporate our aspect into the system, we add the aspect source code to the project and build with the AspectJ compiler, ajc The compiler takes each aspect creates class files that contain the advice code. calls to the appropriate methods in these class files are woven into the original application code In AspectJ this is done at Java bytecode level Output: Lets play “ starwars ”
  • 19.
    Recap of AOPSeparation of concerns (monitoring, synchronisation, debugging, security, etc.) Where What MyAspect In MyProgram Before process { display data print “before process” } MyProgram collect data process data display result Weaver Synchronisation Aspect Business code Classes Monitor Aspect Tangled Classes, Crosscutting Concerns synchronisation monitoring MyProgram collect data display data print “before process” process data display result
  • 20.
    What does allthese mean? AOP has many potential benefits provides a way of specifying and encapsulating cross-cutting concerns in a system. allow us to do a better job of maintaining systems as they evolve let us add new features, in the form of concerns, to existing systems in an organized manner. improvements in expressiveness and structure helps us to keep systems running longer, without incurring the expense of a complete rewrite. a great addition to quality professionals’ toolboxes. Ability to test application code automatically without disturbing the code.
  • 21.
    AOP – aprism analogy
  • 22.
    Early Aspects &AOSD research Early Aspects Separating aspects and concerns at early stages of software development life cycle. Main AOSD research interests: Semantics of AO Languages and Formal Methods (Composition, Join point, Pointcuts, Advices, Weaving) Aspects in Early Life cycle Steps Design of concerns Dynamic Aspects and Infrastructure Software
  • 23.
    Among the MostPopular downloads ©2005 ACM 0001-0782/05/0400 $5.00 Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Communications of the ACM, Volume 48, No 4 (Apr 2005), Pages 33-34
  • 24.
    Conclusion AOP Modularizedimplementation of crosscutting concerns Easier-to-evolve systems Late binding of design decisions More code reuse If software system comprises of crosscutting concerns consider learning more about AOP
  • 25.
    Latest AOSD conference(2005, March 22-26, Chicago, Illinois) Using AspectJ to Build a Product Line for Mobile Devices Developing Embedded Software Product Lines with AspectC++ Aspect-Oriented Programming with Caesar Developing Dynamic and Adaptable Applications with CAM/DAOP: A Virtual Office Application PROSE - A middleware platform for dynamic adaptation Microsoft Phoenix: A Framework for Software Analysis and Optimization
  • 26.
    References Many tools,papers, and other resources related to aspect-oriented software development here: http:// aosd.net Read more about Xerox's AspectJ, a free AOP implementation for Java: http:// aspectj.org Ramnivas Laddad's "XML APIs for Databases" ( JavaWorld, January 2000) explains how to blend the power of XML and databases using custom SAX and DOM APIs : http://www.javaworld.com/javaworld/jw-01-2000/jw-01-dbxml.html Communications of the ACM , October 2001, has many articles on AOSD Past AOSD Conferences http://aosd.net/conference Grundy, J. “Aspect-oriented Requirements Engineering for Component-based Software Systems”, 4th IEEE International Symposium on Requirements Engineering, IEEE Computer Society, Limerick, Ireland, 1999, pp. 84-91 IBM Research. MDSOC: Software Engineering Using Hyperspaces, http:// www.research.ibm.com /hyperspace/ Moreira, A., Araújo, J., Brito, I. “Crosscutting Quality Attributes for Requirements Engineering”, 14th International Conference on Software Engineering and Knowledge Engineering (SEKE 2002), ACM Press, Italy, July 2002. Rashid, A., Sawyer, P., Moreira, A. and Araújo, J. “Early Aspects: a Model for Aspect-Oriented Requirements Engineering”, IEEE Joint Conference Workshop on “Aspect-oriented Modeling with UML”. http://lglwww.epfl.ch/workshops/aosd-uml/ Workshop on “Early Aspects: Aspect-Oriented Requirements Engineering and Architecture Design”. http://trese.cs.utwente.nl/AOSD-EarlyAspectsWS/