UML Lecture
UML Lecture
UML Lecture
Yi Luo
Acknowledgements
■ Slides material are taken from different
sources including:
➢ the slides of Mr. Shiyuan Jin’s UML class, EEL 4884, Fall 2003.
Booch ‘91
OMT - 1
How to use UML diagrams to
design software system?
■ Types of UML Diagrams:
➢ Use Case Diagram
➢ Class Diagram
➢ Sequence Diagram
➢ Collaboration Diagram
➢ State Diagram
Borrow Employee
Client
Order Title
Fine Remittance
Supervisor
Use-Case Diagrams
■ Actors: A role that a user plays with respect to the system, including human users
and other systems. e.g., inanimate physical objects (e.g. robot); an external system
that needs some information from the current system.
■ Use case: A set of scenarios that describing an interaction between a user and a
system, including alternatives.
■ Generalization: relationship between one general use case and a special use
case (used for defining special alternatives) Represented by a line with a
triangular arrow head toward the parent use case.
Use-Case Diagrams
Include: a dotted line labeled <<include>> beginning at base
use case and ending with an arrows pointing to the include use
case. The include relationship occurs when a chunk of
behavior is similar across more than one use case. Use
“include” in stead of copying the description of that behavior.
<<include>>
<<extend>>
Use-Case Diagrams
Figure 16.12
The McGraw-Hill Companies, 2005
Use-Case Diagrams
■ Both Make Appointment
and Request Medication
include Check Patient
Record as a subtask
(include)
(TogetherSoft, Inc)
Class diagram
■ A class diagram depicts classes and their interrelationships
Regular Loyalty
Customer Customer
Subtype1 Subtype2
-Inheritance is a required feature of object orientation
-Generalization expresses a parent/child relationship among related classes.
-Used for abstracting details in several layers
OO Relationships: Association
0..1 *
employer teacher
Multiplicity Role
Symbol Meaning
1 One and only one Role
0..1 Zero or one “A given university groups many people;
M..N From M to N (natural language)
some act as students, others as teachers. A
given student belongs to a single university;
* From zero to any positive integer a given teacher may or may not be working
0..* From zero to any positive integer for the university at a particular time.”
1..* From one to any positive integer
Class diagram
* 4
Student Course
has enrolls
Class Student {
Course enrolls[4];
}
Class Course {
Student have[];
}
Oo Relationships: Composition
Whole Class
Class W Association
Models the part–whole relationship
Composition
Also models the part–whole relationship but, in
Class P1 Class P2
addition, Every part may belong to only one
whole, and If the whole is deleted, so are the
parts
Part Classes
[From Dr.David A. Workman] Example:
Example A number of different chess boards: Each square
belongs to only one board. If a chess board is
thrown away, all 64 squares on that board go as
well.
Figure 16.7
The McGraw-Hill Companies, 2005
Relationships: Aggregation
Container Class
Aggregation:
Class C expresses a relationship among instances of related
classes. It is a specific kind of Container-Containee
AGGREGATION
relationship.
Apples Milk
■Aggregations
may form "part of" the association, but may not be essential to it. They
may also exist independent of the aggregate. e.g. Apples may exist
independent of the bag.
Good Practice: CRC Card
Class Responsibility Collaborator
■ easy to describe how classes work by moving cards around; allows to
quickly consider alternatives.
Interaction Diagrams
■ show how objects interact with one another
Picks up
Dial tone
Dial
Picks up
Hello
Sequence Diagram:Object interaction
A B
Self-Call: A message that an
Synchronous
Object sends to itself.
[condition] remove()
Condition
*[for each] remove()
Iteration
Self-Call
Sequence Diagrams – Object Life Spans
■ Creation
➢ Create message
A
➢ Object life starts at that point
■ Activation Create
B
➢ Symbolized by rectangular stripes
is activated.
➢ Rectangle also denotes when
object is deactivated.
■ Deletion
➢ Placing an ‘X’ on lifeline Activation bar
Return
X
➢ Object’s life ends at that point Deletion
Lifeline
Sequence Diagram
4 : title returned ()
•The horizontal dimension shows the
objects participating in the 5: hold title ()
interaction.
5 : title available ()
6 : borrow title ()
•The vertical arrangement of
messages indicates their order. 6 : remove reservation ()
start
6: remove reservation
5: title available
6 : borrow title
1: look up
2: title data
4 : title returned
Catalog
5 : hold title
➢Use a sequence diagram when the transfer of information is the focus of attention
Start End
Unpaid Paid
Invoice created paying Invoice destroying
State Diagrams (Traffic light example)
Ye
w
ll
Car trips
o
Yellow
ti
G
m
r e
e
e
r
Green
n
Event
What UML Modeling tools we use today?
■ List of UML tools http://en.wikipedia.org/wiki/List_of_UML_tools
■ ArgoUML: http://argouml.tigris.org/