SlideShare a Scribd company logo
Chapter 21 - Aspect-oriented Software DevelopmentLecture 11Chapter 21 Aspect-oriented software engineering
Topics coveredThe separation of concernsAspects, join points and pointcutsSoftware engineering with aspects2Chapter 21 Aspect-oriented software engineering
Aspect-oriented software developmentAn approach to software development based around a relatively new type of abstraction - an aspect.Used in conjunction with other approaches - normally object-oriented software engineering.Aspects encapsulate functionality that cross-cuts and co-exists with other functionality.Aspects include a definition of where they should be included in a program as well as code implementing the cross-cutting concern.3Chapter 21 Aspect-oriented software engineering
The separation of concernsThe principle of separation of concerns states that software should be organised 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, etc.) support the separation of concerns.4Chapter 21 Aspect-oriented software engineering
ConcernsConcerns are not program issues but reflect the system requirements and the priorities of the system stakeholders. Examples of concerns are performance, security, specific functionality, etc.By reflecting the separation of concerns in a program, there is clear traceability from requirements to implementation.Core concerns are the functional concerns that relate to the primary purpose of a system; secondary concerns are functional concerns that reflect non-functional and QoS requirements.5Chapter 21 Aspect-oriented software engineering
Stakeholder concernsFunctional concerns which are related to specific functionality to be included in a system.Quality of service concerns which are related to the non-functional behaviour of a system. Policy concerns which are related to the overall policies that govern the use of the system. System concerns which are related to attributes of the system as a whole such as its maintainability or its configurability.Organisational concerns which are related to organisational goals and priorities such as producing a system within budget, making use of existing software assets or maintaining the reputation of an organisation.6Chapter 21 Aspect-oriented software engineering
Cross-cutting concernsCross-cutting concerns are concerns whose implementation cuts across a number of program components.This results in problems when changes to the concern have to be made - the code to be changed is not localised but is in different places across the system.Cross cutting concerns lead to tangling and scattering.7Chapter 21 Aspect-oriented software engineering
Cross-cutting concerns8Chapter 21 Aspect-oriented software engineering
Tangling of buffer management and synchronization codesynchronized void put (SensorRecordrec ) {// Check that there is space in the buffer; wait if notif ( numberOfEntries == bufsize)wait () ;// Add record at end of bufferstore [back] = new SensorRecord (rec.sensorId, rec.sensorVal) ;back = back + 1 ;// If at end of buffer, next entry is at the beginningif (back == bufsize)back = 0 ;numberOfEntries = numberOfEntries + 1 ;// indicate that buffer is availablenotify () ;} // put9Chapter 21 Aspect-oriented software engineering
Scattering of methods implementing secondary concerns10Chapter 21 Aspect-oriented software engineering
Aspects, join points and pointcutsAn aspect is an abstraction which implements a concern. It includes information where it should be included in a program.A join point is a place in a program where an aspect may be included (woven).A pointcut defines where (at which join points) the aspect will be included in the program.11Chapter 21 Aspect-oriented software engineering
Terminology used in aspect-oriented software engineering12Chapter 21 Aspect-oriented software engineering
An authentication aspectaspect authentication{before: call (public void update* (..))   // this is a pointcut	{		// this is the advice that should be executed when woven into		// the executing systemint 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 logoutSystem.Logout (thisUser.uid) ;	}} // authentication 13Chapter 21 Aspect-oriented software engineering
AspectJ - join point modelCall eventsCalls to a method or constructorExecution eventsExecution of a method or constructorInitialisation eventsClass or object initialisationData eventsAccessing or updating a fieldException eventsThe handling of an exception14Chapter 21 Aspect-oriented software engineering
PointcutsIdentifies the specific events with which advice should be associated.Examples of contexts where advice can be woven into a programBefore the execution of a specific methodAfter the normal or exceptional return from a methodWhen a field in an object is modified15Chapter 21 Aspect-oriented software engineering
Aspect weavingAspect weavers process source code and weave the aspects into the program at the specified pointcuts.Three approaches to aspect weavingSource code pre-processingLink-time weavingDynamic, execution-time weaving16Chapter 21 Aspect-oriented software engineering
Aspect weaving17Chapter 21 Aspect-oriented software engineering
Software engineering with aspectsAspects were introduced as a programming concept but, as the notion of concerns comes from requirements, an aspect oriented approach can be adopted at all stages in the system development process.The architecture of an aspect-oriented system is based around a core system plus extensions.The core system implements the primary concerns. Extensions implement secondary and cross-cutting concerns.18Chapter 21 Aspect-oriented software engineering
Core system with extensions19Chapter 21 Aspect-oriented software engineering
Types of extensionSecondary functional extensions Add extra functional capabilities to the core systemPolicy extensionsAdd functional capabilities to support an organisational policy such as securityQoS extensionsAdd functional capabilities to help attain quality of service requirementsInfrastructure extensionsAdd functional capabilities to support the implementation of the system on some platform20Chapter 21 Aspect-oriented software engineering
Key pointsAspect-oriented approach to software development supports the separation of concerns. By representing cross-cutting concerns as aspects, individual concerns can be understood, reused and modified without changing other parts of the program.Tangling occurs when a module in a system includes code that implements different system requirements. Scattering occurs when the implementation of a concern is scattered across several components.Aspects include a pointcut that defines where the aspect will be woven into the program, and advice – the code to implement the cross-cutting concern. Join points are events that can be referenced in a pointcut. To ensure the separation of concerns, systems can be designed as a core system that implements the primary concerns of stakeholders, and a set of extensions that implement secondary concerns.21Chapter 21 Aspect-oriented software engineering
Chapter 21 - Aspect-oriented Software DevelopmentLecture 222Chapter 21 Aspect-oriented software engineering
Concern-oriented requirements engineeringAn approach to requirements engineering that focuses on customer concerns is consistent with aspect-oriented software development.Viewpoints are a way to separate the concerns of different stakeholders.Viewpoints represent the requirements of related groups of stakeholders.Cross-cutting concerns are concerns that are identified by all viewpoints.23Chapter 21 Aspect-oriented software engineering
Viewpoints and Concerns24Chapter 21 Aspect-oriented software engineering
Viewpoints on an equipment inventory system1. Emergency service users1.1	Find a specified type of equipment (e.g., heavy lifting gear)1.2	View equipment available in a specified store1.3	Check-out equipment1.4	Check-in equipment1.5	Arrange equipment to be transported to emergency1.6	Submit damage report1.7	Find store close to emergency2. Emergency planners2.1	Find a specified type of equipment2.2	View equipment available in a specified location2.3	Check-in/cCheck out equipment from a store2.4	Move equipment from one store to another2.6	Order new equipment25Chapter 21 Aspect-oriented software engineering
Viewpoints on an equipment inventory system3. Maintenance staff3.1	Check -in/cCheck -out equipment for maintenance3.2	View equipment available at each store3.3	Find a specified type of equipment3.4	View maintenance schedule for an equipment item3.5	Complete maintenance record for an equipment item3.6	Show all items in a store requiring maintenance26Chapter 21 Aspect-oriented software engineering
Availability-related requirements for the equipment inventory systemAV.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	All transactions shall be logged at the site of the principal system and at the remote standby site.Rationale: This allows these transactions to be replayed and the system databases made consistent.AV.1.2	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.27Chapter 21 Aspect-oriented software engineering
Inventory system - core requirementsC.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.28Chapter 21 Aspect-oriented software engineering
Inventory system - extension requirementsE1.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’.29Chapter 21 Aspect-oriented software engineering
Aspect-oriented design/programmingAspect-oriented designThe process of designing a system that makes use of aspects to implement the cross-cutting concerns and extensions that are identified during the requirements engineering process.Aspect-oriented programmingThe implementation of an aspect-oriented design using an aspect-oriented programming language such as AspectJ.30Chapter 21 Aspect-oriented software engineering
Use-casesA use-case approach can serve as a basis for aspect-oriented software engineering.Each use case represents an aspect.Extension use cases naturally fit the core + extensions architectural model of a systemJacobsen and Ng develop these ideas of using use-cases by introducing new concepts such as use-case slices and use case modules.31Chapter 21 Aspect-oriented software engineering
Use cases from the inventory management system32Chapter 21 Aspect-oriented software engineering
Extension use cases33Chapter 21 Aspect-oriented software engineering
A generic aspect-oriented design process34Chapter 21 Aspect-oriented software engineering
Design activitiesCore system design where you design the system architecture to support the core functionality of the system.Aspect identification and design Starting with the extensions identified in the system requirements, you should analyze these to see if they are aspects in themselves or if they should be broken down into several aspects.Composition design At this stage, you analyze the core system and aspect designs to discover where the aspects should be composed with the core system. Essentially, you are identifying the join points in a program at which aspects will be woven.Chapter 21 Aspect-oriented software engineering35
Design activitiesConflict analysis and resolution Conflicts occur when there is a pointcut clash with different aspects specifying that they should be composed at the same point in the program.Name design is essential to avoid the problem of accidental pointcuts. These occur when, at some program join point, the name accidentally matches that in a pointcut pattern. The advice is therefore unintentionally applied at that point. Chapter 21 Aspect-oriented software engineering36
UML extensionsExpressing an aspect oriented design in the UML requires:A means of modelling aspects using UML stereotypes.A means of specifying the join points where the aspect advice is to be composed with the core system.37Chapter 21 Aspect-oriented software engineering
An aspect-oriented design model38Chapter 21 Aspect-oriented software engineering
Part of a model of an aspect39Chapter 21 Aspect-oriented software engineering
Extension statementIn the method viewItem, after the call to the method getItemInfo, a call to the method displayHistory should be included to display the maintenance record Chapter 21 Aspect-oriented software engineering40
Verification and validationThe process of demonstrating that a program meets it specification (verification) and meets the real needs of its stakeholders (validation)Like any other systems,aspect-oriented systems can be tested as black-boxes using the specification to derive the testsHowever, program inspections and ‘white-box’ testing that relies on the program source code is problematic.Aspects also introduce additional testing problems 41Chapter 21 Aspect-oriented software engineering
Program inspection problemsTo  inspect a program (in a conventional language) effectively, you should be able to read it from right to left and top to bottom.Aspects make this impossible as the program is a web rather than a sequential document. You can’t tell from the source code where an aspect will be woven and executed.Flattening an aspect-oriented program for reading is practically impossible.42Chapter 21 Aspect-oriented software engineering
White box testingThe aim of white box testing is to use source code knowledge to design tests that provide some level of program coverage e.g. each logical branch in a program should be executed at least once.Aspect problemsHow can source code knowledge be used to derive tests?What exactly does test coverage mean?43Chapter 21 Aspect-oriented software engineering
Aspect problemsDeriving a program flow graph of a program with aspects is impossible. It is therefore difficult to design tests systematically that ensure that all combinations of base code and aspects are executed.What does test coverage mean?Code of each aspect executed once?Code of each aspect exeucted once at each join point where aspect woven????44Chapter 21 Aspect-oriented software engineering
Testing problems with aspectsHow should aspects be specified so that tests can be derived?How can aspects be tested independently of the base system?How can aspect interference be tested?How can tests be designed so that all join points are executed and appropriate aspect tests applied?45Chapter 21 Aspect-oriented software engineering
Key pointsTo identify concerns, you may use a viewpoint-oriented approach to requirements engineering to elicit stakeholder requirements and to identify cross-cutting quality of service and policy concerns.The transition from requirements to design can be made by identifying use cases, where each use case represents a stakeholder concern.The problems of inspecting and deriving tests for aspect-oriented programs are a significant barrier to the adoption of aspect-oriented software development in large software projects.46Chapter 21 Aspect-oriented software engineering

More Related Content

What's hot (20)

PPTX
Ch6-Software Engineering 9
Ian Sommerville
 
PPTX
Ch8-Software Engineering 9
Ian Sommerville
 
PPTX
Ch5- Software Engineering 9
Ian Sommerville
 
PPT
Ian Sommerville, Software Engineering, 9th Edition Ch2
Mohammed Romi
 
PPT
Ian Sommerville, Software Engineering, 9th EditionCh 8
Mohammed Romi
 
PPTX
Ian Sommerville, Software Engineering, 9th Edition Ch 4
Mohammed Romi
 
PPTX
Ch7-Software Engineering 9
Ian Sommerville
 
PDF
Requirements Engineering - Stakeholders
Birgit Penzenstadler
 
PPTX
Ch3-Software Engineering 9
Ian Sommerville
 
PPTX
Ch19 systems engineering
software-engineering-book
 
PPTX
Ch4-Software Engineering 9
Ian Sommerville
 
PPTX
Ch23 project planning
software-engineering-book
 
PPTX
Ch7 implementation
software-engineering-book
 
PPTX
Software Design
Anas Bilal
 
PPTX
Ch17-Software Engineering 9
Ian Sommerville
 
PPT
INTRODUCTION TO SOFTWARE ENGINEERING
Preeti Mishra
 
PPT
Ian Sommerville, Software Engineering, 9th Edition Ch1
Mohammed Romi
 
PPT
REQUIREMENT ENGINEERING
Saqib Raza
 
PPTX
Ch7
Mohammed Romi
 
PPTX
Software Architecture and Design
Ra'Fat Al-Msie'deen
 
Ch6-Software Engineering 9
Ian Sommerville
 
Ch8-Software Engineering 9
Ian Sommerville
 
Ch5- Software Engineering 9
Ian Sommerville
 
Ian Sommerville, Software Engineering, 9th Edition Ch2
Mohammed Romi
 
Ian Sommerville, Software Engineering, 9th EditionCh 8
Mohammed Romi
 
Ian Sommerville, Software Engineering, 9th Edition Ch 4
Mohammed Romi
 
Ch7-Software Engineering 9
Ian Sommerville
 
Requirements Engineering - Stakeholders
Birgit Penzenstadler
 
Ch3-Software Engineering 9
Ian Sommerville
 
Ch19 systems engineering
software-engineering-book
 
Ch4-Software Engineering 9
Ian Sommerville
 
Ch23 project planning
software-engineering-book
 
Ch7 implementation
software-engineering-book
 
Software Design
Anas Bilal
 
Ch17-Software Engineering 9
Ian Sommerville
 
INTRODUCTION TO SOFTWARE ENGINEERING
Preeti Mishra
 
Ian Sommerville, Software Engineering, 9th Edition Ch1
Mohammed Romi
 
REQUIREMENT ENGINEERING
Saqib Raza
 
Software Architecture and Design
Ra'Fat Al-Msie'deen
 

Viewers also liked (20)

PPTX
Chap4 RE validation
Ian Sommerville
 
PPTX
Ch23-Software Engineering 9
Ian Sommerville
 
PPTX
Ch24-Software Engineering 9
Ian Sommerville
 
PPTX
Chap1 RE Introduction
Ian Sommerville
 
PPTX
Ch20-Software Engineering 9
Ian Sommerville
 
PPTX
Ch10-Software Engineering 9
Ian Sommerville
 
PPTX
Ch18-Software Engineering 9
Ian Sommerville
 
PPT
Aspect Oriented Software Development
Jignesh Patel
 
PDF
Evolutionary Problems In Aspect Oriented Software Development
kim.mens
 
PDF
Aspect Oriented Software Development
Otavio Ferreira
 
PPTX
Ch19-Software Engineering 9
Ian Sommerville
 
PPTX
Chap2 RE processes
Ian Sommerville
 
PPTX
Ch15-Software Engineering 9
Ian Sommerville
 
PDF
Aspect oriented software development
Maryam Malekzad
 
PDF
Tallium Knowledge Sharing use cases Feb 2017
AquaSPE AG
 
PPT
Aspect oriented architecture
tigneb
 
PPT
Aspect-Oriented Software Development with Use Cases
www.myassignmenthelp.net
 
PPTX
UML for Aspect Oriented Design
Edison Lascano
 
ODP
Aspect-Oriented Technologies
Esteban Abait
 
DOCX
Scrum doc
S.Mostafa Sayyedi
 
Chap4 RE validation
Ian Sommerville
 
Ch23-Software Engineering 9
Ian Sommerville
 
Ch24-Software Engineering 9
Ian Sommerville
 
Chap1 RE Introduction
Ian Sommerville
 
Ch20-Software Engineering 9
Ian Sommerville
 
Ch10-Software Engineering 9
Ian Sommerville
 
Ch18-Software Engineering 9
Ian Sommerville
 
Aspect Oriented Software Development
Jignesh Patel
 
Evolutionary Problems In Aspect Oriented Software Development
kim.mens
 
Aspect Oriented Software Development
Otavio Ferreira
 
Ch19-Software Engineering 9
Ian Sommerville
 
Chap2 RE processes
Ian Sommerville
 
Ch15-Software Engineering 9
Ian Sommerville
 
Aspect oriented software development
Maryam Malekzad
 
Tallium Knowledge Sharing use cases Feb 2017
AquaSPE AG
 
Aspect oriented architecture
tigneb
 
Aspect-Oriented Software Development with Use Cases
www.myassignmenthelp.net
 
UML for Aspect Oriented Design
Edison Lascano
 
Aspect-Oriented Technologies
Esteban Abait
 
Ad

Similar to Ch21-Software Engineering 9 (20)

PPTX
Ch21.pptx
MohammedNouh7
 
PPTX
Aspect Oriented Programming - AOP/AOSD
Can R. PAHALI
 
PDF
Aspect Oriented Software Engineering
Abhay Pai
 
PPTX
Aspect oriented software engineering-draft
Abdelfattah Al Zaqqa
 
PDF
IRJET- A Design Approach for Basic Telecom Operation
IRJET Journal
 
PPTX
Aspect Oriented Programming
Rodger Oates
 
PDF
Aspect Oriented Development
tyrantbrian
 
PPT
ASPECT ORIENTED PROGRAMING(aop)
kvsrteja
 
PDF
Software Engineering with Objects (M363) Final Revision By Kuwait10
Kuwait10
 
PPTX
Aspect Oriented Programming
Shreya Chatterjee
 
PPT
Aop2007
Tuhin_Das
 
PPTX
Aspect-oriented programming
MohamadHayeri1
 
PDF
SRCenabling application development for the internet of things
IEI GSC
 
PPT
Unit IV Software Engineering
Nandhini S
 
PDF
Object Orientation Fundamentals
Pramod Parajuli
 
PPTX
Chapter 1-Object Oriented Software Engineering.pptx
aroraritik30
 
PPTX
SWBOKKA
Koomma
 
PPTX
20CB304 - SE - UNIT V - Digital Notes.pptx
JayaramB11
 
PDF
Developing secure software using Aspect oriented programming
IOSR Journals
 
Ch21.pptx
MohammedNouh7
 
Aspect Oriented Programming - AOP/AOSD
Can R. PAHALI
 
Aspect Oriented Software Engineering
Abhay Pai
 
Aspect oriented software engineering-draft
Abdelfattah Al Zaqqa
 
IRJET- A Design Approach for Basic Telecom Operation
IRJET Journal
 
Aspect Oriented Programming
Rodger Oates
 
Aspect Oriented Development
tyrantbrian
 
ASPECT ORIENTED PROGRAMING(aop)
kvsrteja
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Kuwait10
 
Aspect Oriented Programming
Shreya Chatterjee
 
Aop2007
Tuhin_Das
 
Aspect-oriented programming
MohamadHayeri1
 
SRCenabling application development for the internet of things
IEI GSC
 
Unit IV Software Engineering
Nandhini S
 
Object Orientation Fundamentals
Pramod Parajuli
 
Chapter 1-Object Oriented Software Engineering.pptx
aroraritik30
 
SWBOKKA
Koomma
 
20CB304 - SE - UNIT V - Digital Notes.pptx
JayaramB11
 
Developing secure software using Aspect oriented programming
IOSR Journals
 
Ad

More from Ian Sommerville (6)

PPTX
Chap3 RE elicitation
Ian Sommerville
 
PPTX
Chap5 RE management
Ian Sommerville
 
PPTX
Ch25-Software Engineering 9
Ian Sommerville
 
PPTX
Ch1-Software Engineering 9
Ian Sommerville
 
PPTX
Ch9-Software Engineering 9
Ian Sommerville
 
PPTX
Ch2-Software Engineering 9
Ian Sommerville
 
Chap3 RE elicitation
Ian Sommerville
 
Chap5 RE management
Ian Sommerville
 
Ch25-Software Engineering 9
Ian Sommerville
 
Ch1-Software Engineering 9
Ian Sommerville
 
Ch9-Software Engineering 9
Ian Sommerville
 
Ch2-Software Engineering 9
Ian Sommerville
 

Ch21-Software Engineering 9

  • 1. Chapter 21 - Aspect-oriented Software DevelopmentLecture 11Chapter 21 Aspect-oriented software engineering
  • 2. Topics coveredThe separation of concernsAspects, join points and pointcutsSoftware engineering with aspects2Chapter 21 Aspect-oriented software engineering
  • 3. Aspect-oriented software developmentAn approach to software development based around a relatively new type of abstraction - an aspect.Used in conjunction with other approaches - normally object-oriented software engineering.Aspects encapsulate functionality that cross-cuts and co-exists with other functionality.Aspects include a definition of where they should be included in a program as well as code implementing the cross-cutting concern.3Chapter 21 Aspect-oriented software engineering
  • 4. The separation of concernsThe principle of separation of concerns states that software should be organised 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, etc.) support the separation of concerns.4Chapter 21 Aspect-oriented software engineering
  • 5. ConcernsConcerns are not program issues but reflect the system requirements and the priorities of the system stakeholders. Examples of concerns are performance, security, specific functionality, etc.By reflecting the separation of concerns in a program, there is clear traceability from requirements to implementation.Core concerns are the functional concerns that relate to the primary purpose of a system; secondary concerns are functional concerns that reflect non-functional and QoS requirements.5Chapter 21 Aspect-oriented software engineering
  • 6. Stakeholder concernsFunctional concerns which are related to specific functionality to be included in a system.Quality of service concerns which are related to the non-functional behaviour of a system. Policy concerns which are related to the overall policies that govern the use of the system. System concerns which are related to attributes of the system as a whole such as its maintainability or its configurability.Organisational concerns which are related to organisational goals and priorities such as producing a system within budget, making use of existing software assets or maintaining the reputation of an organisation.6Chapter 21 Aspect-oriented software engineering
  • 7. Cross-cutting concernsCross-cutting concerns are concerns whose implementation cuts across a number of program components.This results in problems when changes to the concern have to be made - the code to be changed is not localised but is in different places across the system.Cross cutting concerns lead to tangling and scattering.7Chapter 21 Aspect-oriented software engineering
  • 8. Cross-cutting concerns8Chapter 21 Aspect-oriented software engineering
  • 9. Tangling of buffer management and synchronization codesynchronized void put (SensorRecordrec ) {// Check that there is space in the buffer; wait if notif ( numberOfEntries == bufsize)wait () ;// Add record at end of bufferstore [back] = new SensorRecord (rec.sensorId, rec.sensorVal) ;back = back + 1 ;// If at end of buffer, next entry is at the beginningif (back == bufsize)back = 0 ;numberOfEntries = numberOfEntries + 1 ;// indicate that buffer is availablenotify () ;} // put9Chapter 21 Aspect-oriented software engineering
  • 10. Scattering of methods implementing secondary concerns10Chapter 21 Aspect-oriented software engineering
  • 11. Aspects, join points and pointcutsAn aspect is an abstraction which implements a concern. It includes information where it should be included in a program.A join point is a place in a program where an aspect may be included (woven).A pointcut defines where (at which join points) the aspect will be included in the program.11Chapter 21 Aspect-oriented software engineering
  • 12. Terminology used in aspect-oriented software engineering12Chapter 21 Aspect-oriented software engineering
  • 13. An authentication aspectaspect authentication{before: call (public void update* (..)) // this is a pointcut { // this is the advice that should be executed when woven into // the executing systemint 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 logoutSystem.Logout (thisUser.uid) ; }} // authentication 13Chapter 21 Aspect-oriented software engineering
  • 14. AspectJ - join point modelCall eventsCalls to a method or constructorExecution eventsExecution of a method or constructorInitialisation eventsClass or object initialisationData eventsAccessing or updating a fieldException eventsThe handling of an exception14Chapter 21 Aspect-oriented software engineering
  • 15. PointcutsIdentifies the specific events with which advice should be associated.Examples of contexts where advice can be woven into a programBefore the execution of a specific methodAfter the normal or exceptional return from a methodWhen a field in an object is modified15Chapter 21 Aspect-oriented software engineering
  • 16. Aspect weavingAspect weavers process source code and weave the aspects into the program at the specified pointcuts.Three approaches to aspect weavingSource code pre-processingLink-time weavingDynamic, execution-time weaving16Chapter 21 Aspect-oriented software engineering
  • 17. Aspect weaving17Chapter 21 Aspect-oriented software engineering
  • 18. Software engineering with aspectsAspects were introduced as a programming concept but, as the notion of concerns comes from requirements, an aspect oriented approach can be adopted at all stages in the system development process.The architecture of an aspect-oriented system is based around a core system plus extensions.The core system implements the primary concerns. Extensions implement secondary and cross-cutting concerns.18Chapter 21 Aspect-oriented software engineering
  • 19. Core system with extensions19Chapter 21 Aspect-oriented software engineering
  • 20. Types of extensionSecondary functional extensions Add extra functional capabilities to the core systemPolicy extensionsAdd functional capabilities to support an organisational policy such as securityQoS extensionsAdd functional capabilities to help attain quality of service requirementsInfrastructure extensionsAdd functional capabilities to support the implementation of the system on some platform20Chapter 21 Aspect-oriented software engineering
  • 21. Key pointsAspect-oriented approach to software development supports the separation of concerns. By representing cross-cutting concerns as aspects, individual concerns can be understood, reused and modified without changing other parts of the program.Tangling occurs when a module in a system includes code that implements different system requirements. Scattering occurs when the implementation of a concern is scattered across several components.Aspects include a pointcut that defines where the aspect will be woven into the program, and advice – the code to implement the cross-cutting concern. Join points are events that can be referenced in a pointcut. To ensure the separation of concerns, systems can be designed as a core system that implements the primary concerns of stakeholders, and a set of extensions that implement secondary concerns.21Chapter 21 Aspect-oriented software engineering
  • 22. Chapter 21 - Aspect-oriented Software DevelopmentLecture 222Chapter 21 Aspect-oriented software engineering
  • 23. Concern-oriented requirements engineeringAn approach to requirements engineering that focuses on customer concerns is consistent with aspect-oriented software development.Viewpoints are a way to separate the concerns of different stakeholders.Viewpoints represent the requirements of related groups of stakeholders.Cross-cutting concerns are concerns that are identified by all viewpoints.23Chapter 21 Aspect-oriented software engineering
  • 24. Viewpoints and Concerns24Chapter 21 Aspect-oriented software engineering
  • 25. Viewpoints on an equipment inventory system1. Emergency service users1.1 Find a specified type of equipment (e.g., heavy lifting gear)1.2 View equipment available in a specified store1.3 Check-out equipment1.4 Check-in equipment1.5 Arrange equipment to be transported to emergency1.6 Submit damage report1.7 Find store close to emergency2. Emergency planners2.1 Find a specified type of equipment2.2 View equipment available in a specified location2.3 Check-in/cCheck out equipment from a store2.4 Move equipment from one store to another2.6 Order new equipment25Chapter 21 Aspect-oriented software engineering
  • 26. Viewpoints on an equipment inventory system3. Maintenance staff3.1 Check -in/cCheck -out equipment for maintenance3.2 View equipment available at each store3.3 Find a specified type of equipment3.4 View maintenance schedule for an equipment item3.5 Complete maintenance record for an equipment item3.6 Show all items in a store requiring maintenance26Chapter 21 Aspect-oriented software engineering
  • 27. Availability-related requirements for the equipment inventory systemAV.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 All transactions shall be logged at the site of the principal system and at the remote standby site.Rationale: This allows these transactions to be replayed and the system databases made consistent.AV.1.2 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.27Chapter 21 Aspect-oriented software engineering
  • 28. Inventory system - core requirementsC.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.28Chapter 21 Aspect-oriented software engineering
  • 29. Inventory system - extension requirementsE1.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’.29Chapter 21 Aspect-oriented software engineering
  • 30. Aspect-oriented design/programmingAspect-oriented designThe process of designing a system that makes use of aspects to implement the cross-cutting concerns and extensions that are identified during the requirements engineering process.Aspect-oriented programmingThe implementation of an aspect-oriented design using an aspect-oriented programming language such as AspectJ.30Chapter 21 Aspect-oriented software engineering
  • 31. Use-casesA use-case approach can serve as a basis for aspect-oriented software engineering.Each use case represents an aspect.Extension use cases naturally fit the core + extensions architectural model of a systemJacobsen and Ng develop these ideas of using use-cases by introducing new concepts such as use-case slices and use case modules.31Chapter 21 Aspect-oriented software engineering
  • 32. Use cases from the inventory management system32Chapter 21 Aspect-oriented software engineering
  • 33. Extension use cases33Chapter 21 Aspect-oriented software engineering
  • 34. A generic aspect-oriented design process34Chapter 21 Aspect-oriented software engineering
  • 35. Design activitiesCore system design where you design the system architecture to support the core functionality of the system.Aspect identification and design Starting with the extensions identified in the system requirements, you should analyze these to see if they are aspects in themselves or if they should be broken down into several aspects.Composition design At this stage, you analyze the core system and aspect designs to discover where the aspects should be composed with the core system. Essentially, you are identifying the join points in a program at which aspects will be woven.Chapter 21 Aspect-oriented software engineering35
  • 36. Design activitiesConflict analysis and resolution Conflicts occur when there is a pointcut clash with different aspects specifying that they should be composed at the same point in the program.Name design is essential to avoid the problem of accidental pointcuts. These occur when, at some program join point, the name accidentally matches that in a pointcut pattern. The advice is therefore unintentionally applied at that point. Chapter 21 Aspect-oriented software engineering36
  • 37. UML extensionsExpressing an aspect oriented design in the UML requires:A means of modelling aspects using UML stereotypes.A means of specifying the join points where the aspect advice is to be composed with the core system.37Chapter 21 Aspect-oriented software engineering
  • 38. An aspect-oriented design model38Chapter 21 Aspect-oriented software engineering
  • 39. Part of a model of an aspect39Chapter 21 Aspect-oriented software engineering
  • 40. Extension statementIn the method viewItem, after the call to the method getItemInfo, a call to the method displayHistory should be included to display the maintenance record Chapter 21 Aspect-oriented software engineering40
  • 41. Verification and validationThe process of demonstrating that a program meets it specification (verification) and meets the real needs of its stakeholders (validation)Like any other systems,aspect-oriented systems can be tested as black-boxes using the specification to derive the testsHowever, program inspections and ‘white-box’ testing that relies on the program source code is problematic.Aspects also introduce additional testing problems 41Chapter 21 Aspect-oriented software engineering
  • 42. Program inspection problemsTo inspect a program (in a conventional language) effectively, you should be able to read it from right to left and top to bottom.Aspects make this impossible as the program is a web rather than a sequential document. You can’t tell from the source code where an aspect will be woven and executed.Flattening an aspect-oriented program for reading is practically impossible.42Chapter 21 Aspect-oriented software engineering
  • 43. White box testingThe aim of white box testing is to use source code knowledge to design tests that provide some level of program coverage e.g. each logical branch in a program should be executed at least once.Aspect problemsHow can source code knowledge be used to derive tests?What exactly does test coverage mean?43Chapter 21 Aspect-oriented software engineering
  • 44. Aspect problemsDeriving a program flow graph of a program with aspects is impossible. It is therefore difficult to design tests systematically that ensure that all combinations of base code and aspects are executed.What does test coverage mean?Code of each aspect executed once?Code of each aspect exeucted once at each join point where aspect woven????44Chapter 21 Aspect-oriented software engineering
  • 45. Testing problems with aspectsHow should aspects be specified so that tests can be derived?How can aspects be tested independently of the base system?How can aspect interference be tested?How can tests be designed so that all join points are executed and appropriate aspect tests applied?45Chapter 21 Aspect-oriented software engineering
  • 46. Key pointsTo identify concerns, you may use a viewpoint-oriented approach to requirements engineering to elicit stakeholder requirements and to identify cross-cutting quality of service and policy concerns.The transition from requirements to design can be made by identifying use cases, where each use case represents a stakeholder concern.The problems of inspecting and deriving tests for aspect-oriented programs are a significant barrier to the adoption of aspect-oriented software development in large software projects.46Chapter 21 Aspect-oriented software engineering