ASPECT ORIENTED PROGRAMING(aop)

1,500 views

Published on

THIS PRESENTATION INTRODUCES TERMINOLOGY AND HOW COMPATIBLE WITH JAVA ETC IN BRIEF

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,500
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
45
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

ASPECT ORIENTED PROGRAMING(aop)

  1. 1. Aspect-oriented programming RAVITEJA.K.V.S
  2. 2. Introduction <ul><li>Currently, the dominant programming paradigm is object-oriented programming that: </li></ul><ul><li>Object orientation is a clever idea, but has certain limitations </li></ul><ul><li>has been presented as a technology that can fundamentally aid software engineering </li></ul><ul><li>is reflected in the entire spectrum of current software development methodologies and tools </li></ul>
  3. 3. Introduction <ul><li>A new programming technique called aspect-oriented programming (AOP): </li></ul><ul><li>makes it possible to clearly express those programs that OOP fail to support </li></ul><ul><li>enables the modularization of crosscutting concerns by supporting a new unit of sw modularity – aspects – that provide encapsulation for crosscutting concerns </li></ul>
  4. 4. What are aspects? <ul><li>The current working definition is: </li></ul><ul><li>modular units that cross-cut the structure of other modular units </li></ul><ul><li>units that is defined in terms of partial information from other units </li></ul><ul><li>exist in both design and implementation </li></ul>
  5. 5. Concerns <ul><li>AOP is based on the idea that computer systems are better programmed by separately specifying the various concerns of a system </li></ul><ul><li>Separation of concerns is an important software engineering principle guiding all stage of a sw development methodology </li></ul><ul><li>Concerns: </li></ul><ul><li>are properties or areas of interest </li></ul><ul><li>can range from high-level notion to low level-notion </li></ul><ul><li>can be functional or nonfunctional (systemic) </li></ul>
  6. 6. Example of crosscutting concerns <ul><li>Consider: </li></ul><ul><li>This requires every method that moves a figure element to do the notification </li></ul><ul><li>the UML for a simple figure editor in which there are two concrete classes of figure element, points and lines </li></ul><ul><li>the concern that the screen manager should be notified whenever a figure element moves </li></ul>
  7. 7. Example of crosscutting concerns Display Figure FigureElement * Point Line getX() getY() getP1 setP1 DisplayUpdating setX(int) setY(int) setP1(Point) setP2(Point) 2 The red box is drawn around every method that must implement this concern DisplayUpdating fits neither inside of nor around the other boxes in the figure DisplayUpdating cuts across the other boxes
  8. 8. What are aspects? <ul><li>Aspects are similar to classes because: </li></ul><ul><li>have type </li></ul><ul><li>can extend classes and other aspects </li></ul><ul><li>can be abstract or concrete </li></ul><ul><li>can have fields, methods, and types as members </li></ul>
  9. 9. aspects vs class <ul><li>Aspect are different than classes because: </li></ul><ul><li>can additionally include as members pointcuts (picks out join points), advice (code that executes at each join point ) </li></ul><ul><li>do not have constructor or finalizer and they cannot be created with the new operator </li></ul><ul><li>priviliged aspects can access private members of other types </li></ul>
  10. 10. What are aspect? <ul><li>Aspects may arise at any stage of the software lifecycle </li></ul><ul><li>Common example of crosscutting aspects are design or architectural constraints, systemic properties or behaviours and features </li></ul>
  11. 11. Examples of how aspects cross-cut components We wanted to implement a distributed digital library that stores documents in many forms and provides a wide range of operations on those documents application components aspects digital database, minimizing network Library printers, traffic, services synchronization constraints, failure handling
  12. 12. Examples of how aspects cross-cut components <ul><li>There are several aspects of concerns, including: </li></ul><ul><li>communication, by which we mean controlling the amount of network bandwidth the application uses by being careful about which objects get copied in remote method calls </li></ul><ul><li>coordination constraints, by which we mean the synchronization rules require to ensure that the component program behaves correctly </li></ul><ul><li>failure handling, by which we mean handling the many different forms of failure that can arise in a distributed system </li></ul>
  13. 13. The role of aspects in software design <ul><li>AOP aims at providing better means of addressing the well-known problem of separation of concerns </li></ul><ul><li>Three basic approaches to addressing the process of separation of concerns: </li></ul><ul><li>language-based </li></ul><ul><li>framework-based </li></ul><ul><li>architecture-oriented </li></ul>
  14. 14. Language-based approach <ul><li>It is based on the definition of a set of language constructs </li></ul><ul><li>Relevant concerns are identified at the problem domain and translated to aspectual construct </li></ul><ul><li>The final application is obtained by weaving the primary structure with the crosscutting aspects </li></ul>
  15. 15. Framework-based approach <ul><li>Provides more flexible constructs </li></ul><ul><li>Concerns are materialized as aspectual classes at the framework level </li></ul><ul><li>Developers can customize these aspects using the mechanism supported by the framework </li></ul><ul><li>These types of framework are known as AO frameworks (explicitly engineers concerns) </li></ul>
  16. 16. Architecture-oriented approach <ul><li>Early identification of concerns using architectural organizational models </li></ul><ul><li>Architectural view-point involves a higher level of abstraction than the previous approaches </li></ul><ul><li>It tipically comprises two stages </li></ul>
  17. 17. Architecture-oriented approach <ul><li>First, developers should determine the problem architecture </li></ul><ul><li>Then, the approach enables several kinds of aspect materialization through different frameworks </li></ul>Concerns are initially mapped to architectural construct
  18. 18. AOP technologies example <ul><li>Empirical analysis based on a simulation case study of the temperature control system (TCS) of a building () </li></ul><ul><li>This comprises a building with rooms requiring specific temperatures and a network consisting of radiators, pipes and a boiler </li></ul><ul><li>To simulate TCS, a simple mathematical model of temporal differential equations specifies the heat flow among the different components </li></ul>
  19. 19. AOP technologies example Relevant aspects in TCS Aspect It refers to how the simulated entities should run Relationships Synchronization Scheduling It basically involves access to shared variables and race condition Description It works together with scheduling It works together with synchronization
  20. 20. AOP technologies example <ul><li>TCS evaluation according to the different implementation </li></ul><ul><li>Analyzed features: scheduling and synchronization </li></ul><ul><li>OO modeling: SS are scattered across the components requiring these facilities (inheritance anomalies) </li></ul><ul><li>EBA: SS are provided as built-in features in the framework. It may be difficult to customize some of these policies </li></ul><ul><li>R-AO – AL: There are specific aspects dealing with SS. They are kept separated, but some problems about the way they interact (aspect composition) may arise </li></ul>
  21. 21. AOP technologies example <ul><li>Several execution of the simulation programs are maded </li></ul><ul><li>TCS performance with the different implementation: </li></ul><ul><li>results were very similar except in the case of R-AO </li></ul><ul><li>similarities found in the study seem to indicate that both EBA and AL run almost like standard code </li></ul>
  22. 22. AOP technologies example <ul><li>To obtain a measure of the complexity of the implementations, it is gathered code statistics (NCSS) about: </li></ul><ul><li>number of methods per class </li></ul><ul><li>the NCSS per methods </li></ul><ul><li>cyclomatic complexity (CNN per methods) </li></ul>In particular, the best results were obtained with EBA (this payoff comes mainly from the autonomy of component and decoupling prescribed by framework).
  23. 23. AOP issues <ul><li>AOP must address both what the programmer can say and how the computer system will realize the program in a program system </li></ul><ul><li>AOP system: </li></ul><ul><li>provides a way of expressing crosscutting concerns </li></ul><ul><li>also ensures these mechanisms are conceptually straighforward and have efficient implementations </li></ul>
  24. 24. AOP issues <ul><li>How an AOP system specifies aspects: </li></ul><ul><li>What composition mechanisms the system provides: </li></ul><ul><li> join points </li></ul><ul><li>aspect parameterization </li></ul><ul><li>d ominant decomposition </li></ul><ul><li>visibility </li></ul><ul><li>mechanism provided </li></ul>
  25. 25. AOP issues <ul><li>Implementation mechanisms: </li></ul><ul><li>Software process: </li></ul><ul><li>static/dynamic distinction </li></ul><ul><li>modular compilation </li></ul><ul><li>target representation </li></ul><ul><li>methodology or framework (the system provides for organizing the system-building activity) </li></ul><ul><li>reusability </li></ul><ul><li>domain-specificity </li></ul>
  26. 26. AspectJ <ul><li>Aspectj is: </li></ul><ul><li>Aspectj enables the modular implementation of a wide range of crosscutting concerns </li></ul><ul><li>a general-purpose Ao extension to Java </li></ul><ul><li>Java platform compatible </li></ul><ul><li>easy to learn and use </li></ul><ul><li>freely available under an Open Source license </li></ul>
  27. 27. AspectJ <ul><li>When written as an aspect the structure of a crosscutting concern is explicit and easy to reason about </li></ul><ul><li>Aspects are modular </li></ul><ul><li>AspectJ enables: </li></ul><ul><li>name-based crosscutting (tend to affect a small number of other classes) </li></ul><ul><li>property-based crosscutting (range from small to large scale) </li></ul>
  28. 28. AspectJ <ul><li>Adoption of it into an existing project can be a straightforward and incremental task: </li></ul><ul><li>The goals of the AspectJ project are to make AOP technology available to a wide range of programmers, to build and support an AspectJ user community </li></ul><ul><li>to begin with development aspects </li></ul><ul><li>other paths are possible,depending on the needs of the projects </li></ul>
  29. 29. What next? <ul><li>Software engineering researchers provide some help to determine if it is beneficial for sw development organization to adopt AOP for building their sw products </li></ul><ul><li>A number of study have been conducted to asses the usefulness of AOP </li></ul><ul><li>Two basic techniques for assessing a programming technology: </li></ul><ul><li>experiments </li></ul><ul><li>case study </li></ul>
  30. 30. What next? <ul><li>Three areas emerge as important in supporting the use of AOP: </li></ul><ul><li>exposing join points </li></ul><ul><li>managing aspect interface </li></ul><ul><li>structuring aspects </li></ul>
  31. 31. Terminology <ul><li>A join point is a well-defined point in the program flow </li></ul><ul><li>A pointcut is a group of join points </li></ul><ul><li>Advice is code that is executed at a pointcut </li></ul><ul><li>Introduction modifies the members of a class and the relationships between classes </li></ul><ul><li>An aspect is a module for handling crosscutting concerns </li></ul><ul><li>Aspects are defined in terms of pointcuts, advice, and introduction </li></ul><ul><ul><li>Aspects are reusable and inheritable </li></ul></ul>
  32. 32. AspectJ example <ul><li>An aspect is defined very much like a class and can have methods, fields, constructors, initializers, named pointcuts and advice </li></ul><ul><li>An example is tracing aspect that prints messages before certain display operation </li></ul><ul><li>The overall effect of this aspect is to print a descriptive message whenever the traced methods are called </li></ul>
  33. 33. AspectJ example Aspect SimpleTracing { pointcut traced() : call (void Display.update () ) || call (void Display.repaint (..) ); before() : traced () { println(“Entering:” + thisJoinPoint); } void println (String str) { <write to appropriate stream> } } Traced identifies calls to several key methods on Display Before advice on this pointcut uses a helper method of the aspect to print a message Advice uses the thisJoinPoint special variable to an object that describes the current join point

×