Académique Documents
Professionnel Documents
Culture Documents
Object Oriented
Programming Techniques
UML Diagrams
Associations
Binary relationships among
Label
classes
(optional)
next figure)
role name
multiplicity
Design
decisions related to
navigation among class relations
unidirectional
bidirectional
Association
Name, Role, Multiplicity
Student
*
Research Proj
advisee
*
proposes
1
1
Professor
advisor
Bi-directional associations
ResearchProj
*
1
Professor
Uni-directional
associations
ResearchProj
*
1
Professor
Reflexive associations
prerequisites
0..*
Course
class Course {
public:
public Course() { }
// the unbounded multiple association
// is stored in a Vector
private ArrayList prerequisites;
Association classes
Association
as class
Example
representation
Person
Company
Contract
Aggregation
Special form
of association
Relationship
aggregation
Strong aggregation
UML aggregation indicator
Properties
transitive
not reflexive
Representation
UML
bicycle
bicycle
part-of
wheel
1
frame
2
wheel
frame
part-of
36..72
spoke
Horiz bar
spoke
Horiz bar
Aggregation Examples
Strong and weak aggregation
1
Bank
1..*
Branch
Customer
Clerck
Director
1
1..*
Staff
Car
Body
Wheel
1
Engine
10
UML Diagrams
Model
11
For a
attributes
operations
constraints
12
Class diagrams
Conceptual level
Catalogue
Component
Assembly
*
CatalogueEntry
Part
13
Class diagrams
Delivery department Detailed level
Adapted from: M.FowlerUML Distilled, Addison Wesley 2000
Customer
{ abstract }
#customerID : String
#address: String
getHistory(): String
Order
- dateReceived : Date
- orderNumber : String
- value : int
- isPrepaid : bool
dispatch()
close()
CorporateCustomer
PersonalCustomer
- creditCardNo : String
- name : String
- creditLimit : int
OrderLine
getHistory(): String
getHistory(): String
- quantity : int
- unitPrice : int
1
1
Product
Prof. Ioan Salomie Programming Techniques
14
Class diagrams
Three perspectives
Conceptual
draw a diagram representing the concepts in the
problem domain
not related to implementation
focused on
functionality
relationships among concepts
Specification
software perspective
behavioural approach (interfaces) not implementation
Implementation
Notes
15
System entities,
System actors
Attributes and
Behavior
UML
16
actor
actor identification
Use-cases
and actors
17
System
actor
Use-case
ATM
withdraw money
client
check balance
Prof. Ioan Salomie Programming Techniques
18
System
Actor
DVM
Use - case
Buy drink
Update stock
Customer
Agent
Collect
Maintenance
Engineer
19
Use-case description
Use
Use-case
document
20
Use-case description
Use
21
Interaction diagrams
Describe how
groups of objects
collaborate
Typically captures the behaviour
of a single use-case
shows the objects involved and the
messages passed among the objects
Shows the
collaboration among
the objects of a use-case
22
Sequence diagrams
Concepts
Message
arrows pointing from a lifeline of a sending object to
the lifeline of a receiving object
messages have names and may have arguments
each message moves the flow of control from one
object to another
Scenario
a use case may contain more scenarios
one of the scenario is the best case scenario
other scenarios can describe different events and
conditions in the use case
example:
use case buy drink from a vending machine
best-case scenario
no change to return scenario (will return the amount and
cancel transaction)
23
Sequence diagrams
Concepts
Activation
24
Sequence diagrams
Buy drink use-case
Vending machine components (objects):
front panel, controller, delivery unit,
store
1. Client inserts the money into machine
front panel
2. The client makes a selection
3. The money go to the controller
4. The controller checks if the selected
item is in the store unit
5. Assuming a best case scenario, the
item exists, the controller updates the
cash and items and ask the delivery
unit to deliver the item from the store
6. The deliver unit delivers the items in
the front of the machine
Prof. Ioan Salomie Programming Techniques
25
Sequence diagrams
Buy drink use-case
Client
: Panel
: Controller
: Delivery
Insert(amount)
Transfer(amount)
Select(item)
Selected(item)
deliver(item)
26
Sequence diagrams
Buy drink use-case
Generic Sequence diagrams
Takes
Another
drink
27
Sequence diagrams
Buy drink use-case
Generic Sequence diagrams
Client
: Panel
: Controller
: Delivery
Insert(amount)
Transfer(amount)
[amount = price]
Select(item)
1
[amount > price
Check for change
2
[can do change]
return(change)
3
[can do change]
deliver the item
deliver(item)
4
deliver(item)
4
[can not do change]
return(amount)
cancel transaction
28
Sequence diagrams
Object Creation and Destruction
: object1
:object2
new Object()
: anObject
: object1
:object2
: anObject
<< destroy>>
29
Sequence diagrams
Iterated messages
1
Assembly
: Assembly
Component
objects
: Component *
: aClient
: Assembly
class
: Component *
cost()
* cost()
30
Activity diagrams
Concepts
transition
branch
a decision point at which there are two or
more possible path of flow of control
single incoming transition
several guarded outgoing transitions
the branch is mutual exclusive
[else] all others are false
guard boolean expression
Prof. Ioan Salomie Programming Techniques
31
Activity diagrams
Concepts
(cont.)
merge
multiple entry transitions
single output
marks the end of conditional behavior
fork
one incoming transition
several outgoing transitions
when the incoming trans. is triggered, the
outgoing transitions are taken in parallel
can specify concurrent programming
join
multiple entry transitions
one outgoing transition
synchronization role
The
32
Activity diagrams
Example Order processing
Adapted from: M.FowlerUML Distilled, Addison Wesley 2000
Start
Receive
Order
Fork
Guard
condition
Prepare
goods
[rush ord]
Activity
Branch
[else]
Overnignt
Delivery
Send
Invoice
Receive
Payment
Regular
Delivery
Merge
Join
Close
Order
End
33
Activity diagrams
Composite activities
[adapted from m.fowler]
Receive
Order
Prepare
goods
Send
Invoice
Delivery
[rush ord]
Overnignt
Delivery
[else]
Receive
Payment
Regular
Delivery
Close
Order
34
Activity diagrams
Swim lanes
The activities and
actions of an
activity diagram can be grouped
into swim lanes
The activities in each lane can be
associated to a department (part) of
an organization
The lane borders are strictly
conceptual delimited
35
Activity diagrams
Swim lanes
Warehouse
Customer
Service
Accounting
Dept.
Receive
Order
Prepare
goods
Send
Invoice
Receive
Payment
Delivery
Close
Order
36
Package diagrams
diagrams help decomposition
of large systems into subsystems
In UML a package is a collection of
modelling elements that are grouped
together because they are logically related
When defining packages, the principles of
cohesion and coupling should be applied
UML Package symbol (see next slide)
may contain:
Package
37
Package diagrams
Ideally
only changing to a class interface should affect any
other class
m.fowler: the art of large-scale design involves
minimizing dependencies
38
Package diagrams
Example
Adapted from: M.FowlerUML Distilled, Addison Wesley 2000
Order Capture
GUI
Graphics
Library
Mailing List
GUI
Order Capture
Application
Mailing List
Application
Domain
Orders
Customers
Database
Interface
{ abstract}
Oracle
Interface
MSQL
Interface
Prof. Ioan Salomie Programming Techniques
39
Component diagrams
System component
physical elements like files, executables, etc.
<<communication>>
Client
Server
40
Component diagrams
<<Header>>
Order.h
Componnet
diagram
showing
dependencies
in C++
Dependency
of a compon.
on the interf.
of another
component
<<includes >>
<<Body>>
Order.cpp
<<o-Code>>
Order.o
<<Exec >>
GenOrder.exe
Component
Dependent
41
Deployment diagrams
Show
42
Deployment diagrams
PC client
DBserver:DEC
JDBC
sun.jdbc
salesDB
Sales syst
43