Professional Documents
Culture Documents
Uml Patterns PDF
Uml Patterns PDF
Object-Oriented Analysis
Object-Oriented Design
Book
(concept)
Domain concept
Design
logical solution
Book
title
print()
Representation in
analysis of concepts
Construction
code
Representation in an
object- oriented
programming language.
6
Iterative Development
Iterative Development
11
Iterative Development
[iteration N]
Requirements Analysis - Design- Implementation - Testing
[iteration N+1]
Requirements Analysis - Design- Implementation - Testing
12
Iterative Development
13
Embracing Change
14
Elaboration
Construction
Transition
time
Preliminary
Iteration
Elaboration
Iter.
Iter. #1
Transition
Iter.
Iter. #2
Milestone
Construction
Release
Final production
release
Each phase and iteration has some risk mitigation focus, and
concludes with a well-defined milestone.
The milestone review provides a point in time to assess how
well key goals have been met and whether the project needs
to be restructured in any way to proceed.
The end of each iteration is a minor release, a stable
executable subset of the final product.
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
Iteration(s)
Iter.
#1
Iter.
#2
Iter.
#n
Iter. Iter.
#n+1 #n+2
Iter.
#m
Iter.
#m+1
Iterations
18
The UP Disciplines
Phases
Process Disciplines
Inception Elaboration
In an iteration you
walk through all
disciplines.
Construction
Transition
Business Modeling
Requirements
Analysis & Design
Implementation
Test
Deployment
Supporting Disciplines
Configuration Mgmt
Management
Environment
Preliminary
Iteration(s)
Iter.
#1
Iter.
#2
Iter.
#n
Iter. Iter.
#n+1 #n+2
Iter.
#m
Iter.
#m+1
Iterations
19
The UP Disciplines
Focus of this
course.
Phases
Process Disciplines
Inception Elaboration
Construction
Transition
Business Modeling
Requirements
Analysis & Design
Implementation
Test
Deployment
Supporting Disciplines
Configuration Mgmt
Management
Environment
Preliminary
Iteration(s)
Iter.
#1
Iter.
#2
Iter.
#n
Iter. Iter.
#n+1 #n+2
Iter.
#m
Iter.
#m+1
Iterations
20
10
21
Reduce risks
11
Inception
23
Inception
24
12
Supplementary specification
Glossary
25
Development Case
13
Understanding Requirements
27
Introduction to Requirements
28
14
29
15
31
32
16
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.
17
18
38
19
NextGen
Supporting actors to
the right: they provide
a service.
Process Sale
Cashier
Handle returns
Process Rental
Payment
Authorization
Service
<<actor>>
Tax Calculator
39
40
20
Iteration 1 Requirements
42
21
43
22
:System
makeNewSale()
addLineItem(itemID, quantity)
Box may enclose an
iteration area.
*[] is an iteration
marker.
description, total
*[more items]
endSale()
total with taxes
makePayment(amount)
change due, receipt
46
23
:Cashier
makeNewSale()
addLineItem(itemID, quantity)
description, total
*[more items]
endSale()
total with taxes
makePayment(amount)
change due, receipt
47
makeNewSale()
addLineItem(itemID, quantity)
endSale()
makePayment(amount)
48
24
49
Domain Models
concepts
associations between concepts
attributes of concepts
50
25
Domain Models
A Domain Model is a
description of things in
the real world.
A concept is an idea,
thing, or object.
Item
*
Stocked-in
1
Store
address
name
51
Store
POS
Sale
A central distinction
between objectoriented and structured
analysis: division by
concepts (objects)
rather than division by
functions.
52
26
53
Example
POS
Specifications, designs, or
descriptions of things
ProductSpecification
Places
Store
Transactions
Sale, Payment
SalesLineItem
Roles of people
Cashier
Store, Bin
27
Item
description
price
serial number
itemID
56
28
Item
description
price
serial number
itemID
ProductSpecification
Add a specification or
description concept when:
description
price
itemID
1
Describes
*
Item
serial number
58
29
Item
Store
Sale
Sales
LineItem
Cashier
Customer
Manager
Payment
Product
Catalog
Product
Specification
59
Adding Associations
An association is a relationship
between concepts that indicates
some meaningful and interesting
connection.
POS
Records-current
1
Sale
Association name
60
30
Examples
Drawer - POS
SalesLineItem - Sale
POS - Store
ItemDescription - Catalog
ItemDescription - Item
SalesLineItem - Sale
Sale - POS
Cashier - Store
* High-priority associations
61
Multiplicity
Store
Stocks
1
Item
Multiplicity
31
Multiplicity
*
1..*
1..40
5
3, 5, 8
Zero or more;
many
One or more
One to forty
Exactly five
63
Naming Associations
Store
1
Contains
1..*
POS
Captures
1..*
Sale
Paid-by
1
Payment
64
32
*
Flight
Flies-to 0..1
Airport
Flies-from
*
It is not uncommon to
have multiple
associations between
two types.
In the example, not
every flight is
guaranteed to land at
an airport.
65
Adding Attributes
Sale
date
startTime: Time
Attributes
66
33
Cashier
Not a simple
attribute
name
currentRegister
Register
Cashier
number
uses
1
1
name
67
Product
Catalog
Contains
quantity
1..*
Contained-in
1
Sale
1
Logs-completed
*
date
time
1
Paid-by
Payment
amount
Captured-on
1
1
Initiated-by
Described-by
1
Customer
1 Records-sale-of
Product
Specification
description
price
itemID
1
1..*
1
Used-by
*
Describes
Store
Stocks *
address
name
1
*
1 Houses
1..*
POS
Started-by
1
1
1..*
Item
Manager
1
Records-sales-on
Cashier
1
68
34
69
Contracts
35
System
makeNewSale()
addLineItem(itemID, quantity)
endSale()
makePayment()
71
36
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
77
addLineItem
(itemID, quantity)
endSale()
System
makeNewSale()
addLineItem(itemID, quantity)
endSale()
makePayment()
makePayment()
Use Case
System
Sequence
Diagram
System
Operations
Operation:
makeNewSale
...
Operation:
addLineItem
...
Operation:
endSale
...
Operation:
makePayment
...
Contracts
78
39
79
Introduction
message1( )
:ClassAInstance
1: message2()
2: message3()
:ClassBInstance
Interaction diagrams
illustrate how objects
interact via messages.
Collaboration diagrams
illustrate object
interactions in a graph
or network format.
80
40
Introduction
:ClassAInstance
:ClassBInstance
message1()
message2()
message3()
Sequence diagrams
illustrate interactions in
a kind of fence format.
Set of all operation
contracts defines
system behavior.
We will create an
interaction diagram for
each operation
contract.
81
:Register
parameter
first message
1: makePayment(cash Tendered)
link line
:Sale
instance
object creation
:Payment
82
41
The message
makePayment is sent to an
instance of Register. The
sender is not identified.
The Register instance
sends the makePayment
message to a Sale
instance.
The Sale instance creates
an instance of a Payment.
1.
:Register
1: makePayment(cashTendered)
2.
:Sale
1.1: create(cashTendered)
3.
:Payment
83
:Sale
makePayment (cashTendered)
makePayment (cashTendered)
create (cashTendered)
:Payment
84
42
Class
:Sale
Instance
s1:Sale
Named instance
To show an instance of
a class, the regular
class box graphic
symbol is used, but the
name is underlined.
Additionally a class
name should be
preceded by a colon.
An instance name can
be used to uniquely
identify the instance.
85
msg1()
:Register
1: clear()
86
43
Creation of Instances
msg1 ( )
:Register
1: create (cashier)
:Sale
The language
independent creation
message is create,
being sent to the
instance being created.
The create message
may include
parameters, indicating
passing of initial values.
87
Creation of Instances
:Register
:Sale
makePayment()
makePayment()
create()
:Payment
88
44
Conditional Messages
msg1 ( )
:Register
1: [new sale]
create (cashier)
:Sale
A conditional message
is shown by following a
sequence number with
a conditional clause in
square brackets, similar
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
:ClassE
2: msg6()
msg1 ( )
:ClassA
:ClassD
1b.1: msg5()
:ClassB
1a.1: msg3()
:ClassC
91
:B
:C
message1()
[x<10] calculate()
[x>15] calculate()
92
46
Iteration or Looping
msg1( )
:Register
Iteration;
Recurrence values omitted
1*: li := nextLineItem():
SalesLineItem
:Sale
msg1( )
Iteration clause
1*: [i :=1..10]
li := nextLineItem(): SalesLineItem
:Register
Iteration is indicated by
following the sequence
number with a star *
This expresses that the
message is being sent
repeatedly, in a loop, to the
receiver.
It is also possible to include
an iteration clause
indicating the recurrence
values.
:Sale
93
94
47
Doing:
Knowing:
96
48
:Sale
makePayment()
create()
:Payment
98
49
Patterns
99
100
50
101
Sale
date
time
Contains
1..*
SalesLineItem
quantity
Described-by
*
Product
Specification
description
price
itemID
It is necessary to know
about all the
SalesLineItem
instances of a sale and
the sum of the
subtotals.
A Sale instance
contains these, i.e. it is
an information expert
for this responsibility.
102
51
t := getTotal()
This is a partial
interaction diagram.
:Sale
103
t := getTotal()
:Sale
1 *: st := getSubtotal()
:SalesLineItem
SalesLineItem should
determine the subtotal.
This means that Sale needs
to send getSubtotal()
messages to each of the
SalesLineItems and sum
the results.
104
52
t := getTotal()
:Sale
1 *: st := getSubtotal()
:SalesLineItem
1.1: p := getPrice()
:ProductSpecification
To fulfil the
responsibility of
knowing and answering
its subtotal, a
SalesLineItem needs to
know the product price.
The ProductSpecification
is the information
expert on answering its
price.
105
Class
Responsibility
Sale
SalesLineItem
ProductSpecification
53
Creator
Problem: Who should be responsible for creating a
new instance of some class?
Solution: Assign class B the responsibility to create
an instance of class A if one or more of the
following is true:
1.
2.
3.
4.
B aggregates A objects.
B contains A objects.
B records instances of A objects.
B has the initializing data that will be passed to A when it
is created (thus B is an Expert with respect to creating A).
107
Creator
Sale
date
time
Contains
1..*
SalesLineItem
quantity
Described-by
*
Product
Specification
description
price
itemID
54
Creator
:Sale
makeLineItem(quantity)
create(quantity)
This assignment of
responsibilities requires
that a makeLineItem
method be defined in
Sale.
:SalesLineItem
109
Low Coupling
110
55
Low Coupling
:Register
:Payment
:Sale
Assume we need to
create a Payment
instance and associate
it with the Sale.
What class should be
responsible for this?
By Creator, Register is
a candidate.
111
Low Coupling
makePayment()
:Register
1: create()
p:Payment
2:addPayment(p)
:Sale
56
Low Coupling
makePayment()
1: makePayment()
:Sale
:Register
1.1. create()
:Payment
An alternative solution
is to create Payment
and associate it with
the Sale.
No coupling between
Register and Payment.
113
Low Coupling
57
High Cohesion
Hard to understand.
Hard to reuse.
Hard to maintain.
Delicate, affected by change.
High Cohesion
:Register
:Sale
makePayment()
create()
p:Payment
addPayment(p)
116
58
High Cohesion
:Register
:Sale
makePayment()
makePayment()
create()
:Payment
An alternative design
delegates the Payment
creation responsibility
to the Sale, which
supports higher
cohesion in the
Register.
This design supports
high cohesion and low
coupling.
117
High Cohesion
Scenarios that illustrate varying degrees of
functional cohesion
Very low cohesion: class responsible for many
things in many different areas.
1.
2.
118
59
High Cohesion
3.
119
Controller
120
60
121
A use-case realization
describes how a use case is
realized in terms of
collaborating objects.
UML interaction diagrams are
used to illustrate use case
realizations.
Recall Process Sale: from
main scenario we identified a
number of system events
(operations)
Each system event was then
described by a contract.
122
61
:Register
makeNewSale()
create()
By Controller.
:Sale
create()
:SalesLineItem
123
Post-conditions:
A SalesLineItem instance sli was created. (instance creation)
sli was associated with the Sale. (association formed)
sli.quantity was set to quantity. (attribute modification)
sli was associated with a ProductSpecification, based on itemID match
(association formed)
addLineItem(itemID, quantity)
2: makeLineItem(spec, quantity)
:Sale
:Register
1: getSpecification(itemID)
2.2: add (sli)
:ProductCatalog
sli:SalesLineItem
1.1: spec:= find(itemID)
:SalesLineItem
:ProductSpecification
124
62
By Creator.
addLineItem(itemID, quantity)
2: makeLineItem(spec, quantity)
:Sale
:Register
1: getSpecification(itemID)
By Expert.
:ProductCatalog
sli:SalesLineItem
1.1: spec:= find(itemID)
:SalesLineItem
:ProductSpecification
This is a multiobject collection. It
contains many instances of
ProductSpecification.
Post-conditions:
endSale()
{s.isComplete = true}
1: becomeComplete()
s:Sale
:Register
By Controller.
By Expert.
126
63
127
Introduction
128
64
:Register
1: spec := getSpecification(itemID)
The getSpecification
message sent from a
Register to a
ProductCatalog, implies
that the ProductCatalog
instance is visible to the
Register instance.
:ProductCatalog
129
Visibility
130
65
Visibility
addLineItem(itemID, quantity)
:Register
1: spec := getSpecification(itemID)
:ProductCatalog
131
Attribute Visibility
66
Attribute Visibility
class Register {
addLineItem(itemID, quantity)
:Register
1: spec := getSpecification(itemID)
:ProductCatalog
spec = catalog.getSpecification(itemID);
133
Parameter Visibility
134
67
Parameter Visibility
makeLineItem(ProductSpecification spec, int quantity) {
}
addLineItem(itemID,quantity)
2: makeLineItem(spec, quantity)
:Register
1: spec := getSpecification(itemID)
:Sale
: ProductCatalog
sli: SalesLineItem
135
Parameter Visibility
// constructor
SalesLineItem(ProductSpecification spec,
int quantity) {
136
68
Local Visibility
Global Visibility
138
69
139
70
Sale
1
Captures
Register
Design Model
1
addLineItem()
Captures
1 Date
isComplete : Boolean
time
Sale
Date
1 isComplete : Boolean
time
makeLineItem()
142
71
An Example DCD
Three section box
Navigability
Sale
Register
Date
isComplete : Boolean
1 time
Captures
1
addLineItem()
makeLineItem()
Type information
143
ProductCatalog
quantity
Store
address
name
Sale
date
isComplete
time
ProductSpecification
description
price
itemID
Payment
amount
SalesLineItem
quantity
144
72
date
isComplete
time
makeLineItem()
:Register
3: makeLineItem(spec, quantity)
:Sale
145
ProductCatalog
endSale()
addLineItem()
makeNewSale()
makePayment()
Store
Address: String
Name: String
addSale()
getSpecification()
ProductSpecification
Payment
description
price
itemID
amount
Sale
date
isComplete: Boolean
time
becomeComplete()
makeLineItem()
makePayment()
getTotal()
SalesLineItem
Quantity: Integer
getSubtotal()
146
73
:ProductCatalog
A sends a message to B.
A creates an instance of B.
74
Sale
Register
Captures
endSale()
addLineItem()
makePayment()
Date
isComplete : Boolean
time
makeLineItem()
Uses
Store
1
address : Address
name : Text
ProductCatalog
addSale()
1
ProductSpecification
Looks-in
getSpecification()
description : Text
price : Money
itemID: itemID
Contains
1
Houses
1
Register
Sale
Captures
endSale()
enterItem()
makePayment()
Describes
Logs-completed
Date : Date
isComplete : Boolean
time : Time
becomeComplete()
makeLineItem()
makePayment()
getTotal()
*
SaleLineItem
Contains
quantity : Integer
getSubtotal()
Payment
amount : Money
1
Paid-by
150
75
151
SalesLineItem
quantity : Integer
ProductSpecification
*
Described-by
description : Text
1
price : Money
itemID : ItemID
getSubtotal():Money
152
76
SalesLineItem
quantity : Integer
ProductSpecification
*
Described-by
description : Text
1
price : Money
itemID : ItemID
getSubtotal():Money
153
SalesLineItem
quantity : Integer
getSubtotal():Money
ProductSpecification
*
description : Text
Described-by
1
price : Money
productSpec itemID : ItemID
154
77
2 : makeLineItem(spec, quantity)
:Register
1:spec := getSpecification(itemID)
:Sale
:ProductCatalog
1.1:spec := find(itemID)
:ProductSpecification
2.2 : add(sli)
:SalesLineItem
sli:SalesLineItem
155
sale.makeLineItem(spec, quantity);
156
78
ProductCatalog
getSpecification()
1
Looks-in
Register
Captures
endSale()
addLineItem()
makeNewSale()
makePayment()
Sale
Date : Date
isComplete : Boolean
time : Time
becomeComplete()
makeLineItem()
makePayment()
getTotal()
157
SalesLineItem
Contains
1
1 .. *
quantity : Integer
getSubtotal():Money
158
79
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
Store
address
merchantId
name
AuthorizationService
address
merchantId
name
phoneNumber
166
83
Association Classes
AuthorizationService
Authorizes-payment-via
address
name
1..*
address
name
phoneNumber
ServiceContract
Purchases
Sells
1..*
merchantId
*
167
Association Classes
Store
address
name
Authorizes-payment-via
*
1..*
address
name
phoneNumber
ServiceContract
merchantId
An association class.
Its attributes are related to
the association.
Its lifetime is dependent on
the association.
168
84
Company
*
Employment
salary
Person
170
85
Product
Catalog
1..*
Product
Specification
Composite aggregation
or composition means
that the multiplicity at
the composite end may
be at most one
signified with a filled
diamond).
ProductCatalog is an
aggregate of
ProductSpecification.
171
References
UMLPackage
*
UMLElement
Shared aggregation
means that the
multiplicity at the
composite end may be
more than one
(signified with a hollow
diamond).
It implies that the part
may be in many
composite instances.
172
86
173
Sale
SalesLineItem
1
1..*
174
87
Flight
Flies-to
City
destination
175
a discrete concept, or
expressed as a role in an association.
176
88
Roles in associations
manager
*
Employs-to-handle sales
Store
Person
1
*
worker
manager
Manages
177
Roles as concepts
Store
Employs
1
Manager
Manages
1
Employs
Cashier
*
178
89
Derived Elements
SalesLineItem
1
/quantity
1..*
Derivable from the number of
instances of Items associated with
the line item.
Sale
Can be derived from SalesLineItem
and ProductSpecification
information.
Date
/total
time
179
Person
2
parent
*
child
Creates
180
90
Modeling Behavior in
Statechart Diagrams
181
Introduction
182
91
183
184
92
Statechart Diagrams
Telephone
idle
off hook
active
state
on hook
event
transition
185
Statechart Diagrams
186
93
Statechart Diagrams
94
addLineItem
makeNewSale
WaitingForSale
(external)
system
event
makePayment
EnteringItems
endSale
WaitingForPayment
189
190
95
1.
2.
Systems:
Windows:
96
193
194
97
guard (condition)
idle
on hook
195
Idle
on hook
digit
Talking
connected
complete
Dialing
Connecting
digit
196
98
197
Comments on Iterative
Development and the UP
198
99
199
200
100
Control changes.
201
101
203
Other Practices
Extreme Programming
204
102
205
206
103
207
104