Req Specification2017

Download as pdf or txt
Download as pdf or txt
You are on page 1of 65

Modern methods in

Software Engineering

Requirements Analysis

1
Literature used
Text book

Chapter 5

2
Content

Model and reality


Activities during object modeling
Class identification approaches
Aspect Oriented Programming

3
Why models?
Reality R: Real Things, People, Processes
happening during some time, Relationship
between things
Model M: Abstractions from (really existing or
only thought of ) things, people , processes and
relationships between these abstractions.
We use models
To abstract away from details in the reality, so we can
draw complicated conclusions in the reality with
simple steps in the model
To get insights into the past or presence
To make predictions about the future
4
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Models
Models of reality cannot be true
A model is always an approximation
We must say according to our knowledge, or with
todays knowledge
Popper (Objective Knowledge):
We can only build models from reality, which are
true until, we have found a counter example
(Principle of Falsification demonstrating that
relevant details of model are presented incorrectly or
not presented at all)
And even then we might stick with the model (because it
works quite well in most settings)
The falsification principle is the basis of software
development
The goal of prototypes, reviews and system testing is to
falsify the software system 5
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Models
Relationships, which are valid in reality R, are also
valid in model M.
I : Mapping of real things in reality R to abstractions in the
model M (Interpretation)
fM: relationship between abstractions in M
fR: relationship between real things in R

fM
M M
I I
R R
fR
6
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Models
Modeling is relative. We can think of a model as
reality and can build another model from it
(with additional abstractions)
The development of
. Software-Systemes is a
Transformation of
fM2 Models:
M2 M2 Analysis, Design,
Implementation,Testing
Analysis fM1 I2
M1 M1
Requirements
Elicitation I1
R R
fR
7
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Products of Requirements Elicitation
and Analysis
Requirements Requirements
elicitation Specification

nonfunctional
requirements

functional
model

Analysis Analysis Model

dynamic model

analysis object
model

System design

Object design
8
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Analysis model
use case class statechart sequence
diagram:View diagram:View diagram:View diagram:View

functional object dynamic


model:Model model:Model model:Model

analysis
model:Model

9
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
When is a model dominant?
Object model: The system has objects with nontrivial state.
Dynamic model: The model has many different types of
events: Input, output, exceptions, errors, etc.
Functional model: The model performs complicated
transformations (e.g. computations consisting of many
steps).
Which of these models is dominant in the following three
cases?
Compiler
Database system
Spreadsheet program

10
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
When is a model dominant?
Compiler:
The functional model most important.
The dynamic model is trivial because there is only one type input
and only a few outputs.
Database systems:
The object model most important.
The functional model is trivial, because the purpose of the
functions is usually to store, organize and retrieve data.
Spreadsheet program:
The functional model most important.
The dynamic model is interesting if the program allows
computations on a cell.
The object model is trivial, because the spreadsheet values are
trivial and cannot be structured further. The only interesting object
is the cell.
11
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Pieces of an Object Model
Classes
Associations (Relations)
Generic associations
Canonical associations
Part of- Hierarchy (Aggregation)
Kind of-Hierarchy (Generalization)

Attributes
Attributes in one system can be classes in another system

Operations
Generic operations: Get/Set, General world knowledge,
design patterns
Domain operations: Dynamic model, Functional model
12
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Object Modeling
Main goal: Find the important abstractions
What happens if we find the wrong abstractions?
Iterate and correct the model
Steps during object modeling
1. Class identification
Based on the fundamental assumption that we can find abstractions
2. Find the attributes
3. Find the methods
4. Find the associations between classes
Order of steps
Goal: get the desired abstractions
Order of steps secondary, only a heuristic
Iteration is important

13
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Pieces of an Dynamic Model

Sequence diagrams interactions between


objects

State-Chart diagrams behavior of


individual objects

14
Analysis activities
Identify classes/objects
Identify associations, identify aggregates
Identify attributes
Modeling inheritance relationships
Map use cases to objects with Sequence
Diagrams
Model state-dependent behavior of individual
objects
Reviewing the analysis model
15
Class Identification
Class identification is crucial to object-
oriented modeling
Basic assumption:
1. We can find the classes for a new software
system
2. We can identify the classes in an existing
system
Why can we do this?
Philosophy, science, experimental evidence
16
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Class identification
Approaches
Application domain approach:
Ask application domain expert to identify relevant abstractions
Syntactic approach:
Use noun-verb analysis (Abbots technique) to identify components
of the object model (from descriptions or from use cases - extract
participating objects from flow of events)
Common class pattern approach
Use generic classification theory of objects
Design patterns approach
Use reusable design patterns
Component-based approach:
Identify existing solution classes
Object types approach
17
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Mapping parts of speech to object model
components [Abbott, 1983]
Part of speech Model component Example
Proper noun object Jim Smith
Improper noun class Toy, doll
Doing verb method Buy, recommend
being verb inheritance is-a (kind-of)
having verb aggregation has an
modal verb constraint must be
adjective attribute 3 years old
transitive verb method enter
intransitive verb method (event) depends on
18
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Example
Flow of events: The customer enters the store to buy a toy.
It has to be a toy that his daughter likes and it must cost
less than 50 Euro.
He tries a videogame, which uses a data glove and a
head-mounted display. He likes it.
Is this a good use
Case?
An assistant helps him.
The suitability of the game depends on the age of the
child.
Not quite! His daughter is only 3 years old.
The assistant recommends another type of toy, namely the
boardgame Monopoly".

The use case should


terminate with the
19
customer leaving the store
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Textual analysis (Abbots technique)
Example Grammatical construct UML Component
Monopoly" Concrete Person, Thing Object
toy" noun class
"3 years old" Adjective Attribute
enters" verb Operation
depends on." Intransitive verb Operation (Event)

is a" ,either..or", Classifying verb Inheritance


kind of"
"Has a ", consists of" Possessive Verb Aggregation
must be", less than" modal Verb Constraint

20
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Generation of a class diagram from flow of
Customer
events

Flow of events:
store
?
The customer enters the store to buy a toy
toy. It
enter() has to be a toy that his daughter likes and it
Euro He tries a
must cost less than 50 Euro.
daughter videogame which uses a data glove and a
videogame,
age head-mounted display. He likes it.
suitable An assistant helps him. The suitability of the
* game depends on the age of the child. His
toy
price
daughter is only 3 years old. The assistant
buy() recommends another type of toy,
toy namely a
boardgame.
boardgame The customer buy the game and
videogame boardgame leaves the store
21
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Noun-phrase approach
Irrelevant classes are those that are outside the
problem domain
Relevant classes are those that manifestly
belong to the problem domain
Fuzzy classes are those that the analyst cannot
confidently and unanimously classify
as relevant

22
Common class pattern approach
(Bahrami,1999)
Concept class a concept is a notion that a
large community of people share and agree on
Events class an event is something that does
not take time relative to our time scale
Organization class organization is any kind
of purposeful grouping or collection of things
People class "people" is understood here as
a role that a person plays in the system
Places class places are physical locations
relevant to the information system 23
Rumbaugh et al. (1999) propose a
different classification scheme

physical class (e.g. Airplane);


business class (e.g. Reservation);
logical class (e.g. FlightTimetable);
application class (e.g. ReservationTransaction);
computer class (e.g. index);
behavioral class (e.g. ReservationCancellation).

24
Finding Participating Objects in Use Cases
Pick a use case and look at its flow of events
Find terms that developers or users need to clarify in
order to understand the flow of events
Look for recurring nouns (e.g., Incident),
Identify real world entities that the system needs to
keep track of (e.g., FieldOfficer, Dispatcher, Resource),
Identify real world procedures that the system needs to
keep track of (e.g., EmergencyOperationsPlan),
Identify data sources or sinks (e.g., Printer)
Identify interface artifacts (e.g., PoliceStation)
Be prepared that some objects are still missing and
need to be found:
Model the flow of events with a sequence diagram
Always use the users terms
25
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
The CRC (class-responsibility-
collaborators) approach
The CRC approach involves brainstorming sessions,
made easy by the use of specially prepared cards
The cards have three compartments:
Class name
Responsibilities
Collaborations
The CRC approach is an animated process during
which the developers "play cards
They fill cards with class names and assign
responsibilities and collaborators while "executing" a
processing scenario (e.g. a use-case scenario).
26
ReportEmergency: Managing Interactions
among Objects with CRC Cards

ReportEmergencyControl
Incident
Responsibilities Collaborators
Responsibilities Collaborators
Collects input from Field- EmergencyReportForm
officer EmergencyReport Track all information Resource
Controls sequence of AcknowledgementNotice related to a single inci-
forms during emergency dent.
reporting

27
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Mixed approach
In practice, the process of class discovery is likely to be guided
by different approaches at different times
The process is neither top-down nor bottom-up; it is middle-out.
A possible scenario
The initial set of classes may be discovered from the generic knowledge
and experience of analysts
The common class patterns approach can provide additional guidance
Other classes may be added from the analysis of high level descriptions
of the problem domain using the noun phrase approach
If use-case diagrams are available, then the use-case driven approach can
be used to add new and verify existing classes
Finally, the CRC approach will allow brainstorming the list of classes
discovered so far.

28
Do not use concepts of solution
domain in analysis model
Domain concepts that should be represented Software classes that should not be represented
in the analysis object model. in the analysis object model.

Refers to how time zones


UniversalTime TimeZoneDatabase are stored (design
decision).

Denotes to how location is


TimeZone GPSLocator measured (design
decision).

Refers to an internal
Location UserId mechanism for identifying
users (design decision)

29
Class Identification

Design patterns approach (Apply design


knowledge):
Distinguish different types of objects
Apply design patterns

Component-based approach:
Identify existing solution classes

30
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Object Types
Entity Objects
Represent the persistent information tracked by the system
(Application domain objects, Business objects)
Boundary Objects
Represent the interaction between the user and the system
Control Objects:
Represent the control tasks performed by the system
Having three types of objects leads to models that are more
resilient to change.
The interface of a system changes more likely than the control
The control of the system change more likely than the application
domain

31
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Object Types

Year Button
ChangeDate

Month
LCDDisplay

Day

Entity Objects Control Objects Boundary Objects

32
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Naming of Object Types in UML
UML provides several mechanisms to extend the language
UML provides the stereotype mechanism to present new
modeling elements

<<Entity>> <<Boundary>>
Year <<Control>> Button
ChangeDate
<<Entitity>>
Month <<Boundary>>
LCDDisplay
<<Entity>>
Day

Entity Objects Control Objects Boundary Objects

33
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Recommended Naming Convention for
Object Types
To distinguish the different object types on a syntactical basis,
suffixes can be used:
Objects ending with the _Boundary suffix are boundary objects
Objects ending with the _Control suffix are control objects
Entity objects do not have any suffix appended to their name.

Year Button_Boundary
ChangeDate_Control
Month

LCDDisplay_Boundary
Day

34
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Identifying Entity Objects
Heuristics to be used together with Abbots
heuristics:
Terms that developers or users need to clarify in order
to understand the use case
Recurring nouns in the use cases
Real-world entities that the system needs to track
Real-world activities that the system needs to track
Data sources or sinks

35
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Identifying Boundary Objects
Heuristics for identifying boundary objects
Identify user interface controls that the user needs to initiate the
use case
Identify forms the users need to enter data into the system
Identify notices and messages the system uses to respond to the
user
When multiple actors are involved in a use case, identify actor
terminals to refer to user interface under construction
Do not model the visual aspects of the interface with boundary
objects (user mock-ups are better suited for that)
Always use the end user's terms for describing interfaces; do not
use terms from the solution or implementation domains.

36
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Identifying control objects

Heuristics for identifying control objects


Identify one control object per use case.
Identify one control object per actor in the use case.
The life span of a control object should cover the
extent of the use case or the extent of a user session.

37
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Identifying associations
Heuristics for identifying associations
Examine verb phrases (e.g., has, is part of, manages, reports to, is triggered
by, is contained in, talks to, includes).
Name associations and roles precisely.
Use qualifiers as often as possible to identify namespaces and key
attributes.
Do not worry about multiplicity until the set of associations is stable.
Too many associations make a model unreadable.
Eliminate any association that can be derived from other associations.
author document
* writes 1
FieldOfficer EmergencyReport
1 1
reports triggers
Incident
1 1
38
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Identifying Attributes
Heuristics for identifying attributes
Examine possessive phrases or adjective phrases.
Represent stored state as an attribute of the entity object.
Describe each attribute.
Do not waste time describing fine details before the object structure
is stable.

EmergencyReport

emergencyType:{fire,traffic,other}
location:String
description:String

39
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Who uses class diagrams?
Purpose of Class diagrams :
The description of the static properties of a system
(main purpose)
Who uses class diagrams?
The customer and the end user are often not interested
in class diagrams. They usually focus more on the
functionality of the system.
The application domain expert uses class diagrams to
model the application domain
The developer uses class diagrams during the
development of a system, that is, during analysis,
system design, object design and implementation.
40
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Different users of class diagrams
According to the development activity, the
developer plays different roles.
Analyst
System-Designer,
DetailedDesigner
Implementor.
In small systems some of the roles do not exist
or are played by the same person.
Each of these roles has a different view about
the models.
41
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Why do we distinguish these
different users of class diagrams?
Models often dont distinguish between application classes
(address book") and solution class (array", tree").
Reason: Modelling languages like UML allow the use of both types of
classes in the same model.
Preferred : No solution classes in the analysis model.
Many systems dont distinguish between specification and
implementation of a class.
Reason: Object-oriented programming languages allow the simultaneous
use of specification and implementation of a class.
Preferred: The object design model does not contain implementations.
The key for creating high quality software systems is the
exact distinction between
Application and solution domain classes
Interface specification and implementation specification 42
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Dynamic Modeling
Dynamic model consists of:
A collection of multiple state chart diagrams, one state
chart diagram for each class with important dynamic
behavior.
A collection of communication diagrams between objects
Purpose:
Detect and supply methods for the object model
How do we do this?
Start with use case or scenario
Model interaction between objects => sequence diagram
Model dynamic behavior of a single object => statechart
diagram
43
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Sequence Diagram
From the flow of events in the use case or scenario proceed
to the sequence diagram
A sequence diagram is a graphical description of objects
participating in a use case or scenario using a graph
notation
Relation to object identification:
Objects/classes have already been identified during object
modeling
New objects are identified as a result of dynamic modeling
Heuristic:
An event always has a sender and a receiver.
The representation of the event is sometimes called a message
Find objects for each event/message
=> These are the objects participating in the use case
44
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
An Example
Flow of events in a GetPosition use case :

1. Establish connection between smart terminal and


onboard computer

2. Establish connection between onboard computer and


server at Headquarter

3. Get current maintenance expert position and store in


smart terminal

Which are the objects?

45
Sequence Diagram for GetPosition
Smart Terminal Onboard Computer Server
1. Establish
connection
between smart Establish Connection
terminaland Establish Connection
onboard
computer

2. Establish
connection
between Accept Connection
onboard
computer and
server Accept Connection
at headquarter

3. Get current
position and Get Position
store on smart
card 500,575,300
46
time Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Heuristics for Sequence Diagrams
Layout:
1st column: Should correspond to the actor who initiated the use
case
2nd column: Should be a boundary object
3rd column: Should be the control object that manages the rest of
the use case
Creation:
Control objects are created at the initiation of a use case
Other then initial Boundary objects are created by control objects
Access:
Entity objects are accessed by control and boundary objects,
Entity objects should never call boundary or control objects: This
makes it easier to share entity objects across use cases and makes
entity objects resilient against technology-induced changes in
boundary objects.
47
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Is this a good Sequence Diagram?
Smart Terminal Onboard Computer server
First column is
not the actor Establish Connection
Establish Connection
It is not clear
where the
boundary object
is
Accept Connection
It is not clear
where the
control object is Accept Connection

Get Position
500,575,300
48
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Sequence Diagram for GetPosition
Smart Terminal Onboard Computer Server
Driver
new ControlSC
Establish
Connection
Establish
Connection

Accept
Connection

Accept
Connection

Get Position

500,575,300

49
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Fork Diagram
Much of the dynamic behavior is placed in a single object, usually the
control object. It knows all the other objects and often uses them for direct
questions and commands.

50
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Stair Diagram
The dynamic behavior is distributed. Each object delegates some
responsibility to other objects. Each object knows only a few of the other
objects and knows which objects can help with a specific behavior.

51
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Fork or Stair?
Decentralized control structure
The operations have a strong connection
The operations will always be performed in the same
order
Centralized control structure better support of
change (because of encapsulation in one object)
The operations can change order
New operations can be inserted as a result of new
requirements

52
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
State Chart Diagram vs Sequence
Diagram
Sequence diagrams help to identify
The temporal relationship between objects over
time
Sequence of operations as a response to one or
more events
State chart diagrams help to identify:
Changes to an individual object over time

53
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Modeling State-Dependent Behavior of
Individual Objects (Incident)

Active

field officer
arrives on site

Reported Assessment

dispatcher field officer requests


allocates resources additional resources

Response Disengagement

field officer
releases resources

all resources
deallocated when date > 1yr.

Inactive Closed Archived

all resources
submitted reports
54
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Modeling Checklist for the Review
Is the model correct?
A model is correct if it represents the clients view of the the system:
Everything in the model represents an aspect of reality

Is the model complete?


Every scenario through the system, including exceptions, is described.

Is the model consistent?


The model does not have components that contradict themselves (for
example, deliver contradicting results)

Is the model unambiguous?


The model describes one system (one reality), not many

Is the model realistic?


The model can be implemented without problems 55
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Summary
1. What are the functions/transformations? Functional Modeling
Create scenarios and use case diagrams
Talk to client, observe, get historical records, do thought experiments
2. What is the structure of the system? Object Modeling
Create class diagrams
Identify objects.
What are the associations between them? What is their multiplicity?
What are the attributes of the objects?
What operations are defined on the objects?

3. What is its behavior? Dynamic Modeling


Create sequence diagrams
Identify senders and receivers
Show sequence of events exchanged between objects. Identify event
dependencies and event concurrency.
Create state diagrams
Only for the dynamically interesting objects.
56
Adopted from Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java
Aspect-Oriented Programming
(AOP)
Some problems are not attached to any
particular domain but they are spread across
them
OOP assumes knowledge of all needed
interfaces for the developer and interfaces are
not easy to change
OOP composes components vertically while
we might need to compose them horizontally
57
Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ
Fruit and Gadget hierarchy
Fruit Gadget

+peelable +color
+color
+ripeness +turnOn()
+turnOff()
+pick()
+refrigerate()

Grapes Orange Wireless Wired

+peelable +peelable +color +connectionType


+collor +collor
+ripeness +ripeness +acquireSignal() +isConnected()
+receive() +reset()
+pick() +pick()
+refrigerate() +refrigerate()

58
Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ
Fruits and Gadgets as commodities
Packaged item
+wrapper
+numberPerBox

Fruit Gadget
Commodity

+price
+buy()
+sell()

Storage Unit

-SKU
+store()
+retrieve() 59
Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ
Crosscutting concerns

Grapes Orange Wireless Wired

+makeWine() +squeeze() +acquireSignal() +isConnected()


+getSugar() +dryPeel() +receive() +reset()
+drawLabel() +drawLabel() +drawLabel() +drawLabel()
Packed Item
+weigh() +weigh() +weigh() +weigh()
+buy() +buy() +buy() +buy()
+sell() +sell() +sell() +sell() Commodity

+store() +store() +store() +store()


+retrieve() +retrieve() +retrieve() +retrieve() Storage Unit

60
Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ
Room, Reservation and Payment

Room Reservation Payment

checkAvailability() create() Book

assignCustomer() consume() createBill() Check in

removeCustomer() payBill() Check out

61
Adopted from Jacobson, Ng. Aspect-Oriented Software Engineering
A Simplified Example
Class Aspect

Reservation

create() HandleWaitinglist
consume()

Reservation with handling


waiting list

62
Implementation
Join Points special well-defined points in
the program flow where horizontal
extension/bundling appears in the code
Pointcuts predicates that match joint
points
Advices a code which is executed when a
given pointcut is reached

63
Adopted from Ivan Kiselev. Aspect-Oriented Programming with AspectJ
Example continue
class Reservation {
public void create {
...
if(theRoom.getQuantityAvalable()<=0){
throw new NoRoomException() {
...}

aspect HandleWaitingList {
...
pointcut makingReservation():
execution(void Reservation.create());
after throwing (NoRoomException e): makingReservation(){
//code to add customer into waiting list
...
}
64
Next lecture
Text book

Chapters 6 & 7

65

You might also like