Question? Leave a message!




Aspect-Oriented Software Engineering (AOSE)

Aspect-Oriented Software Engineering (AOSE)
Dr.ShaneMatts Profile Pic
Dr.ShaneMatts,United States,Teacher
Published Date:23-07-2017
Website URL
Comment
Chapter 21 Aspect-Oriented Software Engineering (AOSE) Chapter 21 Aspect-Oriented Software Engineering Slide 1 Topics covered  Introduction and motivation  The separation of concerns  Core vs. cross-cutting concerns  Aspects, join points, and pointcuts  Information hiding vs. AOSE  Problems with AOSE (Note: we will NOT cover 21.3, “SE with aspects,” except for 21.3.3, “Verification and Validation”) Chapter 21 Aspect-Oriented Software Engineering Slide 2 Introduction and motivation  In most systems, the mapping between require- ments (“concerns”) and components is not 1:1.  To illustrate, suppose we have “requirements” with just two attributes: color and shape.  Requirements are either red or green, and are either square ( ) or circular ( ).  How should we distribute the requirements among two components if our goal is to minimize the cost of change? (cont’d) Chapter 21 Aspect-Oriented Software Engineering Slide 3 Introduction and motivation (cont’d) (cont’d) Chapter 21 Aspect-Oriented Software Engineering Slide 4 Introduction and motivation (cont’d)  Thus, implementing a requirements change may involve understanding and changing more than one component.  Aspect-Oriented Software Engineering (AOSE) is an approach to SE intended to address this problem.  It is based on a relatively new type of abstraction - an aspect, and is normally used together with OO software engineering. (cont’d) Chapter 21 Aspect-Oriented Software Engineering Slide 5 Introduction and motivation (cont’d)  Aspects encapsulate functionality that cross- cuts other functionality.  R&D in this area has primarily focused on aspect-oriented programming.  Languages such as AspectJ have extended OO languages to include aspects, and have been used in major companies.  AOSE’s focus on separating concerns is an important way of thinking about and structuring software systems, but it is not yet mainstream SE. AspectJ was developed at Xerox PARC and made available in 2001. Chapter 21 Aspect-Oriented Software Engineering Slide 6 The separation of concerns  The principle of separation of concerns states that software should be organized so that each program element does one thing and one thing only.  Each program element should therefore be understandable without reference to other elements.  Program abstractions (subroutines, procedures, objects, and aspects) support the separation of concerns. Chapter 21 Aspect-Oriented Software Engineering Slide 7 What are concerns?  Concerns reflect system requirements and the priorities of system stakeholders.  Examples of concerns are performance, security, specific functionality, etc.  Programs that reflect the separation of concerns in a program  clear traceability from requirements.  This facilitates program understanding and the implementation of requirements change. Chapter 21 Aspect-Oriented Software Engineering Slide 8 Types of concerns (programming and otherwise)  Functional: related to specific functionality to be included in a system.  Quality of service: related to the non-functional behaviour of a system (e.g., performance, reliability, availability).  Policy concerns: related to the overall policies that govern the use of the system.  System: related to attributes of the system as a whole (e.g., maintainability, configurability).  Organizational: related to organizational goals and priorities (e.g., staying within budget, using existing software assets). Chapter 21 Aspect-Oriented Software Engineering Slide 9 Core vs. cross-cutting concerns  Core concerns relate to a system’s primary purpose and are normally implemented within separate procedures, objects, etc.  Cross-cutting concerns are those whose implementation cut across a number of program components, resulting in problems when changes are required due to: • tangling (a component implements multiple requirements), and • scattering (a requirement’s implementation is scattered across more than one component). Chapter 21 Aspect-Oriented Software Engineering Slide 10 Cross-cutting concerns Core concerns New customer Account Customer reqmts reqmts. management reqmts Security reqmts Cross-cutting concerns Recovery reqmts Internet Banking System Chapter 21 Aspect-Oriented Software Engineering Slide 11 (tangling) Cross-cutting concerns Core concerns New customer Account Customer reqmts reqmts. management reqmts tangling Security reqmts Cross-cutting concerns Recovery reqmts Internet Banking System Chapter 21 Aspect-Oriented Software Engineering Slide 12 (tangling) Cross-cutting concerns Core concerns New customer Account Customer reqmts reqmts. management reqmts tangling Security reqmts Cross-cutting concerns Recovery reqmts Internet Banking System scattering Chapter 21 Aspect-Oriented Software Engineering Slide 13 (tangling) Tangling of buffer management and synchronization code synchronized void put (SensorRecord rec ) // Check that there is space in the buffer; wait if not if ( numberOfEntries == bufsize) wait () ; // Add record at end of buffer store back = new SensorRecord (rec.sensorId, rec.sensorVal) ; back = back + 1 ; ensures mutual // If at end of buffer, next entry is at the beginning exclusion if (back == bufsize) back = 0 ; numberOfEntries = numberOfEntries + 1 ; // indicate that buffer is available notify () ; // put Chapter 21 Aspect-Oriented Software Engineering Slide 14 Scattering of methods implementing secondary concerns code associated with secondary statistics collection concern Chapter 21 Aspect-Oriented Software Engineering Slide 15 Aspects, join points, and pointcuts  An aspect is an abstraction which implements a cross-cutting concern.  It includes the code (advice) to be executed and a statement (a pointcut) that defines the events for which the advice is woven into the program.  The program events specified by the pointcut are called join points. Chapter 21 Aspect-Oriented Software Engineering Slide 16 Summary of terminology Term Definition advice The code implementing a concern. aspect A program abstraction that defines a cross-cutting concern. It includes the definition of a pointcut and the advice associated with that concern. join point An event in an executing program where the advice associated with an aspect may be executed. join point model The set of events that may be referenced in a pointcut. pointcut A statement, included in an aspect, that defines the join points where the associated aspect advice should be executed. weaving The incorporation of advice code at the specified join points by an aspect weaver. Chapter 21 Aspect-Oriented Software Engineering Slide 17 AspectJ join point model  Call events: calls to a method or constructor  Execution events: execution of a method or constructor  Initialization events: class or object initialization  Data events: accessing or updating a field  Exception events: the handling of an exception Chapter 21 Aspect-Oriented Software Engineering Slide 18 An “authentication” aspect aspect authentication before: call (public void update (..)) // this is a pointcut // this is the advice that should be executed when woven into // the executing system int tries = 0 ; string userPassword = Password.Get ( tries ) ; while (tries 3 && userPassword = thisUser.password ( ) ) // allow 3 tries to get the password right tries = tries + 1 ; userPassword = Password.Get ( tries ) ; if (userPassword = thisUser.password ( )) then //if password wrong, assume user has forgotten to logout System.Logout (thisUser.uid) ; // authentication Chapter 21 Aspect-Oriented Software Engineering Slide 19 An “authentication” aspect Meaning: Before executing any method whose aspect authentication name starts with “update,” execute the advice. before: call (public void update (..)) // this is a pointcut // this is the advice that should be executed when woven into // the executing system int tries = 0 ; string userPassword = Password.Get ( tries ) ; while (tries 3 && userPassword = thisUser.password ( ) ) // allow 3 tries to get the password right tries = tries + 1 ; userPassword = Password.Get ( tries ) ; if (userPassword = thisUser.password ( )) then //if password wrong, assume user has forgotten to logout System.Logout (thisUser.uid) ; // authentication Chapter 21 Aspect-Oriented Software Engineering Slide 20