Académique Documents
Professionnel Documents
Culture Documents
and
The Unified Modeling Language
UML
Department of Computer Science
Kent State University
UML Part I
Introduction to UML
Overview and Background
J. Maletic
Objectives of UML
UML is a general purpose notation that is
used to
visualize,
specify,
construct, and
document
J. Maletic
Background
UML is the result of an effort to simplify
and consolidate the large number of OO
development methods and notations
Main groups: Booch [91], Rumbaugh [91],
Jacobson [92]
Object Management Group www.omg.org
J. Maletic
Types of Diagrams
Structural Diagrams focus on static
aspects of the software system
Class, Object, Component, Deployment
Structural Diagrams
Class Diagram set of classes and their
relationships. Describes interface to the class (set
of operations describing services)
Object Diagram set of objects (class instances)
and their relationships
Component Diagram logical groupings of
elements and their relationships
Deployment Diagram - set of computational
resources (nodes) that host each component.
J. Maletic
Behavioral Diagram
Use Case Diagram high-level behaviors of the
system, user goals, external entities: actors
Sequence Diagram focus on time ordering of
messages
Collaboration Diagram focus on structural
organization of objects and messages
State Chart Diagram event driven state
changes of system
Activity Diagram flow of control between
activities
J. Maletic
Use Case
Diagram
Analysis
Object Diagram
Specification
Sequence
Diagram
Class Diagram
Collaboration
Diagram
J. Maletic
Design
State Chart
Implementation
Deployment
Diagram
Activity
Diagram
Requirements
Elicitation
Use Case
Diagrams
UML Driven
Process Model
Validate
Object Diagram
Analysis
Sequence
Diagrams
Validate
Class
Diagram
Design
State Chart
Diagrams
Validate
J. Maletic
10
Work Products
Functional Model Use Case diagrams
Analysis Object Model simple object/
class diagram
Dynamic Model State and Sequence
diagrams
Object Design Model Class diagrams
Implementation Model Deployment, and
Activity diagrams
J. Maletic
11
Vocabulary
Functionality
Logic
Implementation
View
Design View
Behavior
Scenarios
Deployment
View
Process View
Performance
Scalability
Throughput
J. Maletic
System topology
Distribution
Delivery
Installation
Kent State University
12
13
Logical Model
Class structure
Object structure
Physical Model
Module architecture
Process architecture
J. Maletic
14
UML Part II
Modeling Requirements
Use Cases
Scenarios
J. Maletic
15
16
Use case
A Use Case
J. Maletic
17
Actor
An Actor
Actors have a name
An actor is a set of roles that users of use
cases play when interacting with the system
They are external entities
They may be external an system or DB
Examples: Customer, Loan officer
J. Maletic
18
19
20
J. Maletic
21
Example
Point of Sale Terminal
Buy Item
Log in
Customer
Cashier
Refund a Purchase
J. Maletic
22
23
include
Clock
Select an Option
User
include
Display Hightest
and Lowest
J. Maletic
24
System Boundary
Store
Buy Item
*
Customer
Refund a Purchase
J. Maletic
25
J. Maletic
26
Example (generalization)
Credit Card Validation
Perform Card
Transaction
Retail Institution
Customer
Process Customer
Bills
inherits
inherits
Individual Custumer
Reconcile
Transaction
Manage Customer
Account
Finacial Institution
Corporate Custumer
J. Maletic
27
J. Maletic
wind chill
dew point temperature
temperature trend
barometric pressure trend
Kent State University
28
29
Hardware Requirements
Use a single board computer (486?)
Time and date are supplied by an on-board clock accessible via
memory mapped I/O
Temperature, barometric pressure, and humidity are measured by on
board circuits with remote sensors.
Wind direction and speed are measure from a boom encompassing a
wind vane (16 directions) and cups (which advance a counter every
revolution)
User input is provided through an off the shelf keypad, managed by
onboard circuit supplying audible feed back for each key press.
Display is off the self LCD with a simple set of graphics primitives.
An onboard timer interrupts the computer every 1/60 second.
J. Maletic
30
Date:
Time:
Temp:
Pressure:
Humidity:
N
W
S
J. Maletic
31
Use Diagrams
Weather Station
Turn System on/off
Set Time/Date
Clock
Set Temperature
Units
User
Calibrate Sensor
Sensor
Display Highest
and Lowest
J. Maletic
32
Scenario: Powering Up
1.
2.
3.
4.
5.
Power is turned on
Each sensor is constructed
User input buffer is initialized
Static elements of display are drawn
Sampling of sensors is initialized
The past high/low values of each primary measurement is set to the value
and time of their first sample.
The temperature and Pressure trends are flat.
The input manager is in the Running state
J. Maletic
33
J. Maletic
34
J. Maletic
35
Use Diagrams
Change Time or Date
include
Clock
Select an Option
User
include
Display Hightest
and Lowest
J. Maletic
36
Summary
A well structured use case:
Names a single identifiable and reasonably
atomic behavior of the system
Factors common behavior by pulling such
behavior from other use cases that include it
Factors variants by pushing such behavior into
other uses cases that extend it
Describes events clearly
Described in a minimal set of scenarios
J. Maletic
37
J. Maletic
38
39
Objects
An object has a state, behavior and identity.
The structure and behavior of similar objects are
defined in their class.
Terms instance and object are interchangeable.
State the properties of an object and the current
values of these properties
Behavior how an object acts and reacts in terms
of its state change and message passing
J. Maletic
40
41
42
43
44
Object Model
J. Maletic
45
Types of Objects
Boundary represent the interactions
between the system and actors
Control represent the tasks that are
performed by the user and supported by the
system
Entity represent the persistent information
tracked by the system
See [Jacobson 99]
J. Maletic
46
A Class in UML
Class name
Attributes
Operators
J. Maletic
Person
-name : string(idl)
-age : int
+print()
Kent State University
47
An Object in UML
object name
and class
J. Maletic
joe : Person
48
-Role1
*
-Role2
0..1
49
consolewindow
J. Maletic
event
dialogbox
control
50
Association
Structural relationship between peer classes
(or objects).
Association can have a name and direction,
or be bi-directional
Role names for each end of the association
Multiplicity of the relationship
J. Maletic
51
Examples of Association
person
person
-employee
-employer
1..*
J. Maletic
company
Works For
company
*
Kent State University
52
Aggregation
Special type of association
Part of relationship
Can use roles and multiplicity
university
department
1
J. Maletic
*
Kent State University
53
Link Attributes
Associations may have properties in the
same manner as objects/classes.
Salary and job title can be represented as
-salary
-title
person
1..*
-employee
J. Maletic
company
-employer
54
Dependency
Represents a using relationship
If a change in specification in one class
effects another class (but not the other way
around) there is a dependency
windspeedSensor
windchill
tempatureSensor
J. Maletic
55
Sensor
Generalization
CalibratingSensor
An is-a relationship
Abstract class
+currentValue()
+calibrate()
HistoricalSensor
WindDirectionSensor
+currentDirection()
-highestValue
-lowestVale
+resetHighest()
+resetLowest()
TrendSensor
-trend
TemperatureSensor
J. Maletic
HumiditySensor
WindspeedSensor
-humidity
-speed
+currentHumidity()
+currentSpeed()
Barometer
-temp
-pressure
+currentTemp()
+currentPressure()
56
57
Object Modeling
Given the high-level requirements (use cases)
Define the object model
Identify objects
Compile a data dictionary
Identify association and aggregations
Identify attributes of objects
Generalize objects into classes
Organized and abstract using inheritance
Iterate and refine model
Group classes into modules/components
J. Maletic
58
J. Maletic
wind chill
dew point temperature
temperature trend
barometric pressure trend
Kent State University
59
60
Use Diagrams
Weather Station
Turn System on/off
Set Time/Date
Clock
Set Temperature
Units
User
Calibrate Sensor
Sensor
Display Highest
and Lowest
J. Maletic
61
Identify Objects
From the vocabulary of the domain
User, clock, sensor, temperature, LCDDisplay,
Keypad, time, date, wind speed, humidity,
barometer, calibrator, metric units, English units,
input manager, sensor sampler, wind direction,
display manager, trend, pressure, current time,
current date, current temp, high temp, low temp,
change temp, change time, power up, power
down, input buffer, trend, key, running, selecting
J. Maletic
62
Eliminate Terms
63
64
Relationships
Top Package::TemperatureSensor
-temp
LCDDevice
+currentTemp()
1
Top Package::HumiditySensor
1
sampler
1
1
displayManager
1
1
-humidity
+currentHumidity()
Top Package::WindDirectionSensor
1
+currentDirection()
Top Package::WindspeedSensor
1
-speed
+currentSpeed()
1
Top Package::Barometer
-pressure
+currentPressure()
J. Maletic
65
Relationships
timeDate
-time
-date
interface
LCDDevice
interface
timer
1
displayManager
windChill
1
1
inputManager
sampler
1
interface
keypad
dewPoint
1
1
windDirection
1
sensors
1
1
1
1
sensor
1
1..*
J. Maletic
66
UML Part IV
Modeling Behavior
Interaction Diagrams
State Chart Diagrams
Activity Diagrams
J. Maletic
67
68
Interaction Diagrams
There is one (or more) Interaction diagram per use case
Represent a sequence of interactions
Made up of objects, links, and messages
Sequence diagrams
Models flow of control by time ordering
Emphasizes passing messages wrt time
Shows simple iteration and branching
Collaboration diagrams
Models flow of control by organization
Structural relationships among instances in the interaction
Shows complex iteration and branching
J. Maletic
69
Sequence Diagrams
X-axis is objects
Object that initiates interaction is left most
Object to the right are increasingly more subordinate
Y-axis is time
Messages sent and received are ordered by time
70
Message Passing
<<create>>
<<destroy>>
J. Maletic
Return
71
p:planningAssistant
<<create>>
:TicketAgent
setItinerary(i)
calculateRoute()
route
<<destroy>>
notify()
J. Maletic
72
Example
S : sampler
WD : sensors
WS : sensors
Temp : sensors
Hum : sensors
J. Maletic
73
S:Caller
:swtich
R:Caller
liftReceiver
setDialtone
dialDigit(d)
routeCall(S,R)
<<CREATE>>
c:converse
ring
liftReceiver
connect
connect
J. Maletic
connect
74
access mailbox
Mail System
retrieve a message
extends
owner
change greeting
add a mailbox
set password
Administrator
delete a message
remove a mailbox
set a user's
password
Leave a message
caller
J. Maletic
75
delete a message
caller
owner
Leave a message
J. Maletic
76
J. Maletic
77
Access Mailbox
recorder : inputReader
sys
: mailbox
: owner
dial(8888)
checkForInput
promptForExtension
dial(dddd)
ext:=getExtension()
create()
ext : extension
verifyExtension
lookup(ext:extension)
Notify
J. Maletic
78
Leave a
message
recorder : inputReader
sys
: mailbox
: caller
dial(dddd)
ext:=getExtension()
create
ext : extension
verifyExtension
promptForMessage
talk()
getMessage
create()
mes : message
hangup
lookup(ext)
saveMessage(mes)
J. Maletic
79
MailSystem
inputReader
+verifyExtension()
-promptForExtension()
-promptForMessage()
-notifyDone()
+getExtension() : extension
+getMessage() : message
+dial()
+hangup()
+checkForInput()
+talk()
1
1
-Administrator
adminMailbox
1
*
-Users
mailbox
+lookup(in mailbox : extension)
+saveMessage(in mess : message)
1
2
extension
messageList
+create()
*
1
message
+create()
J. Maletic
80
J. Maletic
81
Collaboration Diagrams
Emphasizes the organization of the objects
that participate in an interaction
Classifier roles
Association
Messages, flow, and sequencing
J. Maletic
82
Request(order, customer)
2: cost:=researce(order)
orderTaker
CreditBureau
J. Maletic
TicketDB
t)
rcos r)
e
m
me
sto
it(cu it(custo
b
e
3: d ckCred
e
1: ch
83
Leave a Message
1: dial
3: dial
6: talk
2: checkforInput()
4: ext:=getExtension()
7: mess:=getMessage()
inputReader
xt)
e
(
p
oku ess)
o
L
5:
e(m
v
a
8: s
MailSystem
mailbox
J. Maletic
84
Collaboration vs Sequence
The two diagrams really show the same
information
Collaboration diagrams show more static
structure (however, class diagrams are
better at this)
Sequence diagrams clearly highlight the
orderings and very useful for multi-tasking
J. Maletic
85
86
State Diagrams
Finite state machines (i.e., automata, Mealy/
Moore, state transition)
Used to describe the behavior of one object (or
sometimes an operator) for a number of scenarios
that affect the object
They are not good for showing interaction
between objects (use interaction diagrams)
Only use when the behavior of a object is complex
and more detail is needed
J. Maletic
87
88
off
/ FlipSwitch
J. Maletic
89
guard
recieveOrder [amount<25]
Process
order
approve / debitAccount()
action
Confirm
credit
J. Maletic
reject
Cancel
order
90
Activity Diagrams
Special form of a state machine (flow chart)
intended to model computations and
workflows
States of the executing the computation not
the states of an object
Flow between activity states is caused by
the end of a computation rather then an
event
J. Maletic
91
92
Access Mailbox
Retrieve messages
J. Maletic
Change Greeeting
Change password
93
UML Part V
Implementation Diagrams
Component diagrams
Deployment diagrams
J. Maletic
94
Component Diagrams
A component is a physical thing that conforms to
and realizes a set of interfaces
Bridge between logical and physical models
Can represent object libraries, COM components,
Java Beans, etc.
Classes represent logical abstractions, components
represent physical things that reside on a node
(machine).
Components are reachable only through interface
J. Maletic
95
Examples
table
Account
ATM-GUI
Update
Transactions
Dictionary
J. Maletic
spell-check
synonyms
add-new-word
96
Mail System
Mail System
InputReader
Mailbox
J. Maletic
AdminMailbox
97
Deployment Diagrams
Nodes are physical elements that represent a
computational resource (machine)
Association between nodes
Components are allocated to nodes (one or more)
Components represent the physical packaging of
logical elements
Nodes represent the physical deployment of
components
J. Maletic
98
Example
BankServer
-Server
*
*
-Client
ATMKiosk
J. Maletic
99
With Components
BankServer
Update
table
Account
Transactions
1
*
-server
-client
ATMKiosk
ATM-GUI
J. Maletic
100
Weather Station
Keypad
Wind
Direction
Sensor
Tempature
Sensor
J. Maletic
Clock
Computer
Humidity
Sensor
LCD
Display
Wind
Speed
Sensor
Barometer
101
Mailbox.cpp
Mailsystem.cpp
J. Maletic
102