Professional Documents
Culture Documents
Constantinos Constantinides
Computer Science and Software
Engineering
Concordia University
Montreal, Canada
cc@cs.concordia.ca
1
The Need for Software Blueprints
Object-Oriented Analysis
2
Object-Oriented Design
3
Iterative Development and the
Unified Process
4
The Unified Process (UP)
Iterative Development
5
Iterative Development
11
Iterative Development
[iteration N]
Requirements – Analysis - Design- Implementation - Testing
[iteration N+1]
Requirements – Analysis - Design- Implementation - Testing
12
6
Iterative Development
13
Embracing Change
14
7
Iteration Length and Timeboxing
time
8
Iterations and Milestones
Inception Elaboration Construction Transition
Preliminary Iter.
Iter. #1 Iter.
Iter. #2
Iteration
17
The UP Disciplines
Phases
Process Disciplines Inception Elaboration Construction Transition
Business Modeling
Requirements
Analysis & Design
Implementation
Test
Deployment
Supporting Disciplines
Configuration Mgmt
Management
Environment
Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter.
Iteration(s) #1 #2 #n #n+1 #n+2 #m #m+1
Iterations
18
9
The UP Disciplines In an iteration you
walk through all
Phases disciplines.
Process Disciplines Inception Elaboration Construction Transition
Business Modeling
Requirements
Analysis & Design
Implementation
Test
Deployment
Supporting Disciplines
Configuration Mgmt
Management
Environment
Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter.
Iteration(s) #1 #2 #n #n+1 #n+2 #m #m+1
Iterations
19
Business Modeling
Requirements
Analysis & Design
Implementation
Test
Deployment
Supporting Disciplines
Configuration Mgmt
Management
Environment
Preliminary Iter. Iter. Iter. Iter. Iter. Iter. Iter.
Iteration(s) #1 #2 #n #n+1 #n+2 #m #m+1
Iterations
20
10
Disciplines and Phases
21
11
Inception
23
Inception
24
12
What artifacts may start in inception?
25
26
13
Understanding Requirements
27
Introduction to Requirements
Requirements are system capabilities and conditions to which
the system must conform.
Functional requirements
Features and capabilities.
Recorded in the Use Case model (see next), and in the systems
features list of the Vision artifact.
Non-functional (or quality requirements)
Usability (Help, documentation, …), Reliability (Frequency of
failure, recoverability, …), Performance (Response times,
availability, …), Supportability (Adaptability, maintainability, …)
Recorded in the Use Case model or in the Supplementary
Specifications artifact.
The nature of UP supports changing requirements.
28
14
Use-Case Model: Writing
Requirements in Context
29
15
Use cases and adding value
Handle returns
Main success scenario: A customer arrives at a
checkout with items to return. The cashier uses the
POS system to record each returned item…
Alternate scenarios:
If the credit authorization is reject, inform customer
and ask for an alternative payment method.
If item identifier not found in the system, notify the
Cashier and suggest manual entry of the identifier
code.
…
31
32
16
Use case types and formats
33
Fully-dressed example:
Process Sale
Use case UC1: Process Sale
Primary Actor: Cashier
Stakeholders and Interests:
-Cashier: Wants accurate and fast entry, no payment errors, …
-Salesperson: Wants sales commissions updated.
…
Preconditions: Cashier is identified and authenticated.
Success Guarantee (Postconditions):
-Sale is saved. Tax correctly calculated.
…
Main success scenario (or basic flow): [see next slide]
Extensions (or alternative flows): [see next slide]
Special requirements: Touch screen UI, …
Technology and Data Variations List:
-Identifier entered by bar code scanner,…
Open issues: What are the tax law variations? …
34
17
Fully dressed example:
Process Sale (cont.)
Main success scenario (or basic flow):
The Customer arrives at a POS checkout with items to purchase.
The cashier records the identifier for each item. If there is more than
one of the same item, the Cashier can enter the quantity as well.
The system determines the item price and adds the item information to
the running sales transaction. The description and the price of the current
item are presented.
On completion of item entry, the Cashier indicates to the POS system
that item entry is complete.
The System calculates and presents the sale total.
The Cashier tells the customer the total.
The Customer gives a cash payment (“cash tendered”) possibly greater
than the sale total.
35
18
Finding primary actors, goals and use
cases
37
38
19
Use Case Diagrams
Primary actors to Supporting actors to
the left: have user goals. the right: they provide
NextGen
a service.
Process Sale
<<actor>>
Alternative notation for Tax Calculator
computer system actor
39
40
20
Iteration 1 Requirements
41
42
21
Use-Case Model: Drawing System
Sequence Diagrams
43
22
System Behavior and
System Sequence Diagrams (SSDs)
A sequence diagram is a picture that shows,
for a particular scenario of a use case, the
events that external actors generate, their
order, and possible inter-system events.
All systems are treated as a black box; the
diagram places emphasis on events that
cross the system boundary from actors to
systems.
45
addLineItem(itemID, quantity)
Box may enclose an
iteration area. description, total
*[…] is an iteration *[more items]
marker.
endSale()
46
23
SSD and Use Cases
:System
:Cashier
Simple cash-only Process Sale Scenario makeNewSale()
47
48
24
Domain Model: Visualizing
Concepts
49
Domain Models
50
25
Domain Models
A Domain Model is a
Item description of things in
the real world.
*
A Domain Model is not
Stocked-in a description of the
1 software design.
Store
address A concept is an idea,
name
thing, or object.
51
A central distinction
between object-
Store POS Sale oriented and structured
analysis: division by
concepts (objects)
Partial Domain Model. rather than division by
functions.
52
26
Strategies to Identify Conceptual
Classes
Use a conceptual class category list.
Make a list of candidate concepts.
Use noun phrase identification.
Identify noun (and noun phrases) in textual
descriptions of the problem domain, and consider
them as concepts or attributes.
Use Cases are excellent description to draw for
this analysis.
53
Specifications, designs, or
descriptions of things ProductSpecification
Places Store
54
27
Finding Conceptual Classes with
Noun Phrase Identification
1. This use case begins when The fully addressed Use
a Customer arrives at a Cases are an excellent
POS checkout with items description to draw for this
to purchase. analysis.
Some of these noun
2. The Cashier starts a new
phrases are candidate
sale. concepts; some may be
3. Cashier enters item attributes of concepts.
identifier. A mechanical noun-to-
… concept mapping is not
possible, as words in a
natural language are
(sometimes) ambiguous.
55
56
28
The Need for Specification or
Description Conceptual Classes
The memory of the
item’s price was
attached to inventoried
Item instances, which were
deleted.
description
price Notice also that in this
serial number model there is
itemID
duplicated data
(description, price,
itemID).
57
58
29
The NextGen POS (partial) Domain
Model
POS Item Store Sale
Sales
Cashier Customer Manager
LineItem
Product Product
Payment
Catalog Specification
59
Adding Associations
An association is a relationship
“Direction reading arrow” has no meaning
between concepts that indicates other than to indicate direction of reading
some meaningful and interesting the association label.
connection. Optional (often excluded)
Records-current
POS Sale
1 1
Association name
60
30
Finding Associations –Common
Associations List
Category Examples
A is a physical part of B* Drawer - POS
A is a logical part of B SalesLineItem - Sale
A is physically contained in/on B POS - Store
A is logically contained in B ItemDescription - Catalog
A is a description of B ItemDescription - Item
A is a line item of a transaction
or report B SalesLineItem - Sale
A is known/logged/recorded/
captured in B Sale - POS
A is a member of B Cashier - Store
...
(See complete list in Larman 2nd. ed.,
pp. 156-157) * High-priority associations
61
Multiplicity
62
31
Multiplicity
* T Zero or more;
“many”
1..*
T One or more
1..40
T One to forty
5
T Exactly five
63
Naming Associations
64
32
Multiple Associations Between Two
Types
It is not uncommon to
have multiple
associations between
*
Flies-to 0..1 two types.
Flight Airport
Flies-from In the example, not
* 1 every flight is
guaranteed to land at
an airport.
65
Adding Attributes
66
33
Valid Attribute Types
67
68
34
Use-Case Model: Adding Detail
with Operation Contracts
69
Contracts
70
35
System Operations and the System
Interface
In the UML the system
as a whole can be
represented as a class.
System Contracts are written
makeNewSale() for each system
addLineItem(itemID, quantity) operation to describe
endSale() its behavior.
makePayment()
71
72
36
Pre- and Postconditions
73
addLineItem postconditions
74
37
addLineItem postconditions
Attribute Modification
After the itemID and quantity of an item have
been entered by the cashier, what attributes
of new or existing objects should have been
modified?
sli.quantity was set to quantity (attribute
modification).
75
addLineItem postconditions
76
38
Writing Contracts leads to Domain
Model Updates
It is also common to discover the need to
record new concepts, attributes or
associations in the Domain Model.
77
Operation:
makeNewSale()
makeNewSale
System ...
addLineItem Operation:
Use Case: makeNewSale()
(itemID, quantity) addLineItem
addLineItem(itemID, quantity)
Process Sale ...
endSale() endSale()
makePayment() Operation:
endSale
makePayment() ...
Operation:
makePayment
...
System
Sequence System
Use Case Diagram Operations Contracts
78
39
Interaction Diagram Notation
79
Introduction
Interaction diagrams
message1( )
illustrate how objects
interact via messages.
:ClassAInstance
Collaboration diagrams
1: message2() illustrate object
2: message3() interactions in a graph
or network format.
:ClassBInstance
80
40
Introduction
Sequence diagrams
illustrate interactions in
:ClassAInstance :ClassBInstance
a kind of fence format.
message1() Set of all operation
contracts defines
message2()
system behavior.
We will create an
message3()
interaction diagram for
each operation
contract.
81
82
41
How to Read the makePayment
Collaboration Diagram
makePayment(cashTendered) 1. The message
makePayment is sent to an
instance of Register. The
:Register sender is not identified.
1: makePayment(cashTendered)
2. The Register instance
sends the makePayment
message to a Sale
:Sale
instance.
1.1: create(cashTendered) 3. The Sale instance creates
an instance of a Payment.
:Payment
83
:Register :Sale
makePayment (cashTendered)
makePayment (cashTendered)
create (cashTendered)
:Payment
84
42
Illustrating Classes and Instances
To show an instance of
Sale Class a class, the regular
class box graphic
symbol is used, but the
:Sale Instance name is underlined.
Additionally a class
name should be
s1:Sale Named instance preceded by a colon.
An instance name can
be used to uniquely
identify the instance.
85
1: clear()
86
43
Creation of Instances
The language
msg1 ( )
independent creation
message is create,
1: create (cashier) being sent to the
:Register :Sale instance being created.
The create message
may include
newly created instance parameters, indicating
passing of initial values.
87
Creation of Instances
88
44
Conditional Messages
A conditional message
is shown by following a
msg1 ( )
sequence number with
a conditional clause in
1: [new sale] square brackets, similar
create (cashier)
:Register :Sale to the iteration clause.
The message is sent
only if the clause
evaluates to true.
89
Conditional Messages
:A :B
message1()
[color=red] calculate()
90
45
Mutually Exclusive Conditional Paths
1a and 1b are mutually
exclusive conditional paths.
unconditional
after either msg2() Both are sequence number 1
or msg4() :ClassE since either could be the first
internal message.
2: msg6()
91
:A :B :C
message1()
[x<10] calculate()
[x>15] calculate()
92
46
Iteration or Looping
Iteration;
msg1( ) Recurrence values omitted
Iteration is indicated by
following the sequence
number with a star *
1*: li := nextLineItem():
SalesLineItem This expresses that the
:Register :Sale message is being sent
repeatedly, in a loop, to the
receiver.
It is also possible to include
Iteration clause an iteration clause
msg1( )
indicating the recurrence
1*: [i :=1..10] values.
li := nextLineItem(): SalesLineItem
:Register :Sale
93
94
47
Responsibilities and Methods
95
96
48
Responsibilities and Methods
97
98
49
Patterns
99
100
50
Information Expert (or Expert)
101
It is necessary to know
Sale
date about all the
time SalesLineItem
Contains
instances of a sale and
1..*
the sum of the
SalesLineItem Described-by Product
subtotals.
1
Specification
A Sale instance
quantity *
description contains these, i.e. it is
price
itemID an information expert
for this responsibility.
102
51
Information Expert (or Expert)
This is a partial
t := getTotal() interaction diagram.
:Sale
103
104
52
Information Expert (or Expert)
To fulfil the
t := getTotal() responsibility of
:Sale
knowing and answering
its subtotal, a
SalesLineItem needs to
1 *: st := getSubtotal()
know the product price.
:SalesLineItem The ProductSpecification
is the information
1.1: p := getPrice() expert on answering its
:ProductSpecification price.
105
106
53
Creator
107
Creator
108
54
Creator
This assignment of
responsibilities requires
:Sale that a makeLineItem
method be defined in
makeLineItem(quantity) Sale.
create(quantity)
:SalesLineItem
109
Low Coupling
Coupling: it is a measure of how strongly one element is
connected to, has knowledge of, or relies upon other elements.
A class with high coupling depends on many other classes
(libraries, tools).
Problems because of a design with high coupling:
Changes in related classes force local changes.
110
55
Low Coupling
Assume we need to
create a Payment
instance and associate
it with the Sale.
:Register :Payment :Sale What class should be
responsible for this?
By Creator, Register is
a candidate.
111
Low Coupling
112
56
Low Coupling
113
Low Coupling
114
57
High Cohesion
115
High Cohesion
116
58
High Cohesion
An alternative design
delegates the Payment
:Register :Sale creation responsibility
to the Sale, which
makePayment() supports higher
cohesion in the
makePayment() Register.
create() This design supports
:Payment
high cohesion and low
coupling.
117
High Cohesion
118
59
High Cohesion
119
Controller
120
60
Use Case Realizations
121
122
61
Object Design: makeNewSale
We work through the postcondition state changes
and design message interactions to satisfy the
requirements.
By Controller. create()
:SalesLineItem
123
addLineItem(itemID, quantity)
2: makeLineItem(spec, quantity)
:Register :Sale
1: getSpecification(itemID)
2.2: add (sli) 2.1: create (spec, quantity)
:ProductCatalog
sli:SalesLineItem
1.1: spec:= find(itemID)
:SalesLineItem
:ProductSpecification
124
62
Object Design: addLineItem
By Controller. By Creator.
addLineItem(itemID, quantity)
2: makeLineItem(spec, quantity)
:Register :Sale
:ProductSpecification
125
{
public void becomeComplete() { UML notation for a constraint
isComplete = true;
}
}
{s.isComplete = true}
endSale() 1: becomeComplete()
:Register s:Sale
By Controller. By Expert.
126
63
Design Model: Determining
Visibility
127
Introduction
128
64
Visibility Between Objects
:ProductCatalog
129
Visibility
130
65
Visibility
131
Attribute Visibility
66
Attribute Visibility
133
Parameter Visibility
134
67
Parameter Visibility
makeLineItem(ProductSpecification spec, int quantity) {
…
sli = new SalesLineItem(spec, quantity);
…
}
:Register :Sale
135
Parameter Visibility
136
68
Local Visibility
addLineItem(itemID, quantity) {
…
ProductSpecification spec = catalog.getSpecification(itemID);
...
}
137
Global Visibility
138
69
Design Model: Creating Design
Class Diagrams
139
70
DCD and UP Terminology
141
Register Sale
Design Model Date
1 Captures 1 isComplete : Boolean
addLineItem(…) time
… makeLineItem()
142
71
An Example DCD
Three section box Navigability
Register Sale
Date
isComplete : Boolean
1 Captures 1 time
addLineItem(…)
… makeLineItem()
143
Sale
Store SalesLineItem
address date
quantity
name isComplete
time
144
72
Creating a NextGen POS DCD
interaction diagrams.
Sale
If the message makeLineItem is
sent to an instance of class date
Sale, then class Sale must isComplete
define a makeLineItem method. time
makeLineItem()
3: makeLineItem(spec, quantity)
:Register :Sale
145
… description amount
price
endSale() getSpecification() itemID
addLineItem()
makeNewSale()
makePayment() Sale
date SalesLineItem
isComplete: Boolean
Store time Quantity: Integer
146
73
Method Names -Multiobjects
147
74
Creating a NextGen POS DCD
Register class will probably Navigability arrow indicates
have an attribute pointing to a Register objects are connected
Sale object. uni-directionally to Sale objects.
Register Sale
Date
1 Captures 1 isComplete : Boolean
time
endSale()
addLineItem()
makeLineItem()
makePayment()
149
150
75
Implementation Model: Mapping
Designs to Code
151
ProductSpecification
SalesLineItem description : Text
* Described-by 1
quantity : Integer price : Money
itemID : ItemID
getSubtotal():Money
152
76
Adding Reference Attributes
ProductSpecification
SalesLineItem description : Text
* Described-by 1
quantity : Integer price : Money
itemID : ItemID
getSubtotal():Money
153
ProductSpecification
SalesLineItem description : Text
* Described-by 1
quantity : Integer price : Money
productSpec itemID : ItemID
getSubtotal():Money
154
77
Creating Methods from Interaction
Diagrams
addLineItem(itemID, quantity)
2 : makeLineItem(spec, quantity)
:Register
:ProductCatalog
:ProductSpecification sli:SalesLineItem
:SalesLineItem
155
156
78
A Skeletal definition of Register Class
public class Register {
1 Sale
Register
Date : Date
Captures isComplete : Boolean
1 1 time : Time
endSale()
becomeComplete()
addLineItem()
makeLineItem()
makeNewSale()
makePayment()
makePayment()
getTotal()
157
158
79
Iteration 2 and its Requirements
159
From Iteration 1 to 2
160
80
From Iteration 1 to 2
161
162
81
Iteration 3 Emphasis
163
164
82
Association Classes
165
Association Classes
166
83
Association Classes
Store AuthorizationService
Authorizes-payment-via
address address
* 1..* name
name
phoneNumber
ServiceContract
Purchases Sells
merchantId *
1..*
167
Association Classes
The merchantId is an attribute related to the association
between the Store and AuthorizationService; it depends on
their relationship.
ServiceContract may then be modeled as an association
class.
Store AuthorizationService
Authorizes-payment-via
address address
* 1..* name
name
phoneNumber
ServiceContract
An association class.
merchantId Its attributes are related to
the association.
Its lifetime is dependent on
the association.
168
84
Guidelines for Association Classes
An attribute is related to an association.
Instances of the association class have a life-time dependency on
the association.
There is a many-to-many association between two concepts.
The presence of a many-to-many association between two concepts
is a clue that a useful associative type should exist in the
background somewhere.
Company Employs
Person
* *
169
170
85
Composite Aggregation - Filled
diamond
Composite aggregation
or composition means
that the multiplicity at
the composite end may
Product Product
Catalog Specification
be at most one
1 1..* signified with a filled
diamond).
ProductCatalog is an
aggregate of
ProductSpecification.
171
Shared aggregation
means that the
multiplicity at the
composite end may be
References more than one
UMLPackage UMLElement
* *
(signified with a hollow
diamond).
It implies that the part
may be in many
composite instances.
172
86
How to identify Aggregation
173
174
87
Association Role Names
175
176
88
“Roles in associations”
Employs-to-manage
1 * manager
Employs-to-handle sales *
Store Person
1 *
manager worker
Manages
177
“Roles as concepts”
1 Employs 1
Store * Manager
Manages
1
Employs
*
Cashier
*
178
89
Derived Elements
Sale
Can be derived from SalesLineItem
Date
and ProductSpecification
/total information.
time
179
Creates
180
90
Modeling Behavior in
Statechart Diagrams
181
Introduction
182
91
Events, States and Transitions
183
184
92
Statechart Diagrams
Telephone
It is common to include an initial pseudo-state
which automatically transitions to another state
when the instance is created.
on hook
event
transition
185
Statechart Diagrams
186
93
Statechart Diagrams
187
188
94
Use Case Statechart Diagrams
addLineItem
makeNewSale
WaitingForSale EnteringItems
(external)
system
event endSale
makePayment
WaitingForPayment
189
190
95
Classes that Benefit from Statechart
Diagrams
1. State-independent and State Dependent Objects
An entity is considered to be state-independent if it
responds in the same manner to all events.
An object receives a message and the corresponding
method always does the same thing. The object is state-
independent with respect to that message.
If, for all events of interest, an object always reacts the
same way, it is a state-independent object.
An entity is considered to be state-dependent if it
responds differently to events.
State diagrams are created for state-dependent entities
with complex behavior.
191
192
96
Illustrating External and Internal
Events
External event: caused by something outside
a system boundary.
SSDs illustrate external events.
Internal event: caused by something inside
the system boundary.
Messages in interaction diagrams suggest internal
events.
193
194
97
Additional Statechart Diagram
Notation
idle Active
on hook
195
connected
digit
on hook
complete
Dialing Connecting
digit
196
98
Additional Statechart Diagram
Notation
A state allows nesting to contain substates. A
substate inherits the transitions of its
superstate (the enclosing state).
Within the Active state, and no matter what
substate the object is in, if the on hook event
occurs, a transition to the idle state occurs.
197
Comments on Iterative
Development and the UP
198
99
Additional UP Best Practices and
Concepts
The central idea behind the UP is short
timeboxed iterative, adaptive development.
Tackle high-risk and high-value issues in
early iterations.
Leave easier work in later iterations.
This way the project does not “fail late”
Better to “fail early” if at all.
199
200
100
Additional UP Best Practices and
Concepts
Apply Use Cases.
Use Cases explore and record functional requirements.
Capture requirements, used for design, testing and writing
end-user documentation.
UML supports abstract (and visual) models of
software.
Carefully manage requirements.
“Poor requirements management is a common factor on
troubled projects” [Standish, 1994]
Control changes.
UP embraces change, not chaos.
201
202
101
The Construction and Transition Phases
203
Other Practices
Extreme Programming
Write a unit test before the code to be tested, and
write tests for all classes.
http://www.extremeprogramming.org/
SCRUM process pattern
Focuses on team behavior.
http://www.controlchaos.com
204
102
Motivations for Timeboxing an Iteration
205
206
103
Some Problems with the Waterfall
Lifecycle
Tackling high-risk or difficult problems late.
In a waterfall lifecycle there is no attempt to identify and
tackle riskiest issues first.
In an iterative development (like the UP) early iterations
focus on driving down the risk.
Requirements speculation and inflexibility.
The waterfall process assumes that requirements can be
fully specified and then frozen in the first phase of the
project.
Stakeholders want to see something concrete very early.
Market changes.
In iterative development requirements tend to stabilize after
several iterations.
207
208
104