際際滷

際際滷Share a Scribd company logo
1

Aspect-oriented
software
engineering
ABDELFATTAH AL ZAQQA
PSUT-AMMAN-JORDAN
Topics covered


The separation of concerns



Aspects, join points and pointcuts



Software engineering with aspects

2
Introduction-Problem
Requirements

Req

3

Complex
Relationship

Program
components

R1

Program
comp.

R2

C1

R3

C2
C3
Complex
Change on
Requirements



4

Needs

Even in reuse components (remove extra code)

understanding
and changing
several
components
AOSE

5

address
AOSE

Complexity
Problem
Maintain and
reuse easily
Program
End intro

6
Aspects, join points, and pointcuts


7

Example: Assume that we have medical records system such as MHCPMS.
handle
MHCPMS components

Holds Prescribed
medication

Patient info.

Holds Personal
Info.

updatePersonalInformation (patientId, infoupdate)
updateMedication (patientId, medicationupdate)

by authorized
person only
solutions


Problem: Somehow illegal update happen



Solutions:

1.

re-authentication before any change tangled implementation
authentication with logging or not, where?!.

2.

Modify system to do authentication each time update method
called  scattered implementation. every call?! Several different
place?

* Cross cutting between authentication and logging

8
An authentication aspect in Aspect
9
Where it will be
Oriented system
woven into
aspect authentication
program
{
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 ) ;
Advice
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
Terminology used in aspectoriented software engineering
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.
An event in an executing program where the advice
associated with an aspect may be executed.
The set of events that may be referenced in a pointcut.

join point

Not
standard

join point model
pointcut

weaving

A statement, included in an aspect, that defines the join
points where the associated aspect advice should be
executed.
The incorporation of advice code at the specified join
points by an aspect weaver.

10
aspect authentication
{
before: call (public void update* (..)) // this is a pointcut
Monitor: Execution (System.Logout (thisUser.uid) )
{public void get(System.systime)
}
{
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) ;
}
after: call (public void update* (..))
{
public void logging(userID.Get(uid)
}
} // authentication

11
12
Source code preprocessing

Rarely used

Link time
weaving, modify
compiler

Most common

Dynamic
weaving at
execution time

More flexible
End Aspects, join points, and
pointcuts

13
Concern-oriented requirements
engineering
Req1.

Req2.

Req3.

Req6.

Req5.

ReqC

Req4.

14

 organize the
requirements
according to stakeholder
viewpoint.
 you can then analyze
them to discover related
requirements that
appear in all or most
viewpoints.
Viewpoints and Concerns

Cross-cutting concerns are concerns that are
identified by all viewpoints.

15
Viewpoints on an equipment
inventory system
1. Emergency service users
1.1
Find a specified type of equipment (e.g., heavy
lifting gear)
1.2
View equipment available in a specified store
1.3
Check-out equipment
1.4
Check-in equipment
1.5
Arrange equipment to be transported to emergency
1.6
Submit damage report
1.7
Find store close to emergency
2. Emergency planners
2.1
Find a specified type of equipment
2.2
View equipment available in a specified location
2.3
Check-in/cCheck out equipment from a store
2.4
Move equipment from one store to another
2.6
Order new equipment

16

3. Maintenance staff
3.1
Check -in/cCheck -out equipment for
maintenance
3.2
View equipment available at each
store
3.3
Find a specified type of equipment
3.4
View maintenance schedule for an
equipment item
3.5
Complete maintenance record for an
equipment item
3.6
Show all items in a store requiring
maintenance
Viewpoints on an equipment
inventory system

Maintenance
staff

Emergency
service
users

Emergency
planners

1. Find a specified type of equipment
2. View equipment available in a
specified location
3. Check-in/cCheck out equipment
from a store

17
Availability-related requirements for
the equipment inventory system
AV.1
There shall be a hot standby system available in a location
that is geographically well-separated from the principal system.
Rationale: The emergency may affect the principal location of the
system.
AV.1.1 The system shall send status information to the emergency
control room system every five minutes.
Rationale: The operators of the control room system can switch to the
hot standby if the principal system is unavailable.

18
Inventory system - core
requirements


C.1 The system shall allow authorised users to view the description of
any item of equipment in the emergency services inventory.



C.2 The system shall include a search facility to allow authorised
users to search either individual inventories or the complete
inventory for a specific item or type of equipment.

19
Inventory system - extension
requirements


E1.1 It shall be possible for authorised users to place orders with
accredited suppliers for replacement items of equipment.



E1.1.1 When an item of equipment is ordered, it should be allocated
to a specific inventory and flagged in that inventory as on order.

20
General rule


many concerns or extensions to the system confuse the reader and
may lead to premature design.



limits the freedom of designers and may result in a system design
that cannot meet its quality of service requirements.

21
End Concern-oriented
requirements engineering

22

More Related Content

Aspect oriented software engineering-draft

  • 2. Topics covered The separation of concerns Aspects, join points and pointcuts Software engineering with aspects 2
  • 4. Complex Change on Requirements 4 Needs Even in reuse components (remove extra code) understanding and changing several components
  • 7. Aspects, join points, and pointcuts 7 Example: Assume that we have medical records system such as MHCPMS. handle MHCPMS components Holds Prescribed medication Patient info. Holds Personal Info. updatePersonalInformation (patientId, infoupdate) updateMedication (patientId, medicationupdate) by authorized person only
  • 8. solutions Problem: Somehow illegal update happen Solutions: 1. re-authentication before any change tangled implementation authentication with logging or not, where?!. 2. Modify system to do authentication each time update method called scattered implementation. every call?! Several different place? * Cross cutting between authentication and logging 8
  • 9. An authentication aspect in Aspect 9 Where it will be Oriented system woven into aspect authentication program { 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 ) ; Advice 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
  • 10. Terminology used in aspectoriented software engineering 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. An event in an executing program where the advice associated with an aspect may be executed. The set of events that may be referenced in a pointcut. join point Not standard join point model pointcut weaving A statement, included in an aspect, that defines the join points where the associated aspect advice should be executed. The incorporation of advice code at the specified join points by an aspect weaver. 10
  • 11. aspect authentication { before: call (public void update* (..)) // this is a pointcut Monitor: Execution (System.Logout (thisUser.uid) ) {public void get(System.systime) } { 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) ; } after: call (public void update* (..)) { public void logging(userID.Get(uid) } } // authentication 11
  • 12. 12 Source code preprocessing Rarely used Link time weaving, modify compiler Most common Dynamic weaving at execution time More flexible
  • 13. End Aspects, join points, and pointcuts 13
  • 14. Concern-oriented requirements engineering Req1. Req2. Req3. Req6. Req5. ReqC Req4. 14 organize the requirements according to stakeholder viewpoint. you can then analyze them to discover related requirements that appear in all or most viewpoints.
  • 15. Viewpoints and Concerns Cross-cutting concerns are concerns that are identified by all viewpoints. 15
  • 16. Viewpoints on an equipment inventory system 1. Emergency service users 1.1 Find a specified type of equipment (e.g., heavy lifting gear) 1.2 View equipment available in a specified store 1.3 Check-out equipment 1.4 Check-in equipment 1.5 Arrange equipment to be transported to emergency 1.6 Submit damage report 1.7 Find store close to emergency 2. Emergency planners 2.1 Find a specified type of equipment 2.2 View equipment available in a specified location 2.3 Check-in/cCheck out equipment from a store 2.4 Move equipment from one store to another 2.6 Order new equipment 16 3. Maintenance staff 3.1 Check -in/cCheck -out equipment for maintenance 3.2 View equipment available at each store 3.3 Find a specified type of equipment 3.4 View maintenance schedule for an equipment item 3.5 Complete maintenance record for an equipment item 3.6 Show all items in a store requiring maintenance
  • 17. Viewpoints on an equipment inventory system Maintenance staff Emergency service users Emergency planners 1. Find a specified type of equipment 2. View equipment available in a specified location 3. Check-in/cCheck out equipment from a store 17
  • 18. Availability-related requirements for the equipment inventory system AV.1 There shall be a hot standby system available in a location that is geographically well-separated from the principal system. Rationale: The emergency may affect the principal location of the system. AV.1.1 The system shall send status information to the emergency control room system every five minutes. Rationale: The operators of the control room system can switch to the hot standby if the principal system is unavailable. 18
  • 19. Inventory system - core requirements C.1 The system shall allow authorised users to view the description of any item of equipment in the emergency services inventory. C.2 The system shall include a search facility to allow authorised users to search either individual inventories or the complete inventory for a specific item or type of equipment. 19
  • 20. Inventory system - extension requirements E1.1 It shall be possible for authorised users to place orders with accredited suppliers for replacement items of equipment. E1.1.1 When an item of equipment is ordered, it should be allocated to a specific inventory and flagged in that inventory as on order. 20
  • 21. General rule many concerns or extensions to the system confuse the reader and may lead to premature design. limits the freedom of designers and may result in a system design that cannot meet its quality of service requirements. 21