The document discusses aspect-oriented software engineering. It covers topics like separation of concerns, aspects, join points, and pointcuts. It provides an example of how an authentication aspect can be used to add authentication logic before any update method is called in a way that avoids tangled or scattered code. It discusses terminology like advice, pointcut, and weaving. It also discusses different approaches for weaving aspects into code like source code preprocessing, link time weaving, and dynamic weaving. Finally, it discusses concern-oriented requirements engineering and using viewpoints to identify cross-cutting concerns in requirements.
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
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