0% found this document useful (0 votes)
76 views22 pages

Aspect-Oriented Software Development: ©ian Sommerville 2006 Slide 1

Aspect-oriented Software Development is an approach to software development based around a new type of abstraction - an aspect. Concerns are not program issues but reflect the system requirements and the priorities of the system stakeholders. By reflecting the separation of concerns in a program there is clear traceability from requirements to implementation.

Uploaded by

Ali Butt
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views22 pages

Aspect-Oriented Software Development: ©ian Sommerville 2006 Slide 1

Aspect-oriented Software Development is an approach to software development based around a new type of abstraction - an aspect. Concerns are not program issues but reflect the system requirements and the priorities of the system stakeholders. By reflecting the separation of concerns in a program there is clear traceability from requirements to implementation.

Uploaded by

Ali Butt
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

Aspect-oriented Software Development

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 1

Objectives

To explain the principle of separation of concerns in software development To introduce the fundamental ideas underlying aspect-oriented development To show how an aspect-oriented approach can be used at all stages of development To discuss problems of testing aspect-oriented systems

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 2

Topics covered

The separation of concerns Aspects, join points and pointcuts Software engineering with aspects

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 3

Aspect-oriented software development

An approach to software development based around a 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.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 4

The separation of concerns

The 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.
Software Engineering, 8th edition. Chapter 32 Slide 5

Ian Sommerville 2006

Concerns

Concerns 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.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 6

Stakeholder concerns

Functional 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.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 7

Cross-cutting concerns

Cross-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.
Software Engineering, 8th edition. Chapter 32 Slide 8

Ian Sommerville 2006

Cross-cutting concerns
New cu stomer req . Acco un t req . Cu stomer management req.

Cros s-cuttin g concern s Security req . Reco very req.

Co re co ncerns

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 9

Tangling

synchronized void put (SensorR ecord rec ) throws InterruptedException { if ( numberOfE ntries == bufsize) wait () ; store [back] = new SensorRecord (rec.sensorId, rec.sensor Val) ; back = back + 1 ; if (back == bufsize) back = 0 ; numberOfEntries= numberOfEn tries + 1 ; notify () ; } // put

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 10

Scattering
Patien t <attribute d ecls> getName () editN ame () getAdd ress () editA ddress () ... anon ymis e () ... Image <attribute d ecls> getMod ality () archive () getDate () editD ate () ... s av eDiag no sis () s av eTyp e () ... Co ns ultatio n <attribute d ecls> makeApp oint () can celAp po in t () ass ig nNu rs e () bo ok Equ ip () ... anon ymis e () s av eCo ns ult () ...

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 11

Aspects, join points and pointcuts

An 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.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 12

Aspect terminology
Term Definiti on

advice aspect

join point join point model pointcut

weaving

T he code implementing a concern. A program abstr action 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. T he set of events that may be referenced in a pointcut. A statement, included in an aspect, that defines the join points where the associated aspect advice should be executed. T he incorporation of advice code at the specified join points by an aspect weaver.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 13

An authentication aspect
aspect authentication { before: call (public void update * (..)) // this is a pointcut { // this is the advice that should be e xe cuted when woven in to // the e xecuting system int tries = 0 ; string userPassword = Password.Ge t ( trie s ) ; while (trie s < 3 && userPassword != thisUser.password ( ) ) { // al ow 3 tries to ge t the password right l tries = tries + 1 ; use rPassword = Password.Ge t ( tries ) ; } if (use rPassword != thisUser.password ( )) then //if password wrong, assum e use r h forgotten to logout as Syste m.Logout (thisUse r.uid) ; } } // authentication
Ian Sommerville 2006 Software Engineering, 8th edition. Chapter 32 Slide 14

AspectJ - join point model

Call events
Calls to a method or constructor

Execution events
Execution of a method or constructor
Class or object initialisation Accessing or updating a field The handling of an exception

Initialisation events

Data events

Exception events

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 15

Pointcuts

Identifies the specific events with which advice should be associated. Examples of contexts where advice can be woven into a program
Before the execution of a specific method After the normal or exceptional return from a method When a field in an object is modified

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 16

Aspect weaving

Aspect weavers process source code and weave the aspects into the program at the specified pointcuts. Three approaches to aspect weaving
Source code pre-processing Link-time weaving Dynamic, execution-time weaving

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 17

Aspect weaving

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 18

Software engineering with aspects

Aspects 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.
Software Engineering, 8th edition. Chapter 32 Slide 19

Ian Sommerville 2006

Core system + extensions


Ext 1 Ext 2 Ext 3

Co re sy stem

Ext 4

Ext 5

Ext 6

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 20

Types of extension

Secondary functional extensions


Add extra functional capabilities to the core system Add functional capabilities to support an organisational policy such as security Add functional capabilities to help attain quality of service requirements Add functional capabilities to support the implementation of the system on some platform

Policy extensions

QoS extensions

Infrastructure extensions

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 21

Key points

The key benefit of an aspect-oriented approach is that it supports the separation of concerns. Tangling occurs when a module implements several requirements; Scattering occurs when the implementation of a single concern is spread across several components. Systems may be designed as a core system with extensions to implement secondary concerns.

Ian Sommerville 2006

Software Engineering, 8th edition. Chapter 32

Slide 22

You might also like