Introduction To UML: Majid Ali Khan
Introduction To UML: Majid Ali Khan
Introduction To UML: Majid Ali Khan
Acknowledgements
www.sts.tu-harburg.de/ teaching/ws98.99/OOA+D/3-0-UML.pdf
Overview
What is Modeling?
What is UML?
A brief history of UML
Understanding the basics of UML
UML diagrams
UML Modeling tools
Modeling
What is UML?
History of UML
Class Diagram
Sequence Diagram
Collaboration Diagram
State Diagram
Use Case
Actor
Library System
Borrow
Employee
Client
Order Title
Fine Remittance
Supervisor
(TogetherSoft, Inc)
Class diagram
Class representation
Name
Attributes
Operations
+ is used to denote Public visibility (everyone)
# is used to denote Protected visibility (friends and derived)
- is used to denote Private visibility (no one)
An example of Class
Account_Name
- Customer_Name
- Balance
+addFunds( )
+withDraw( )
+transfer( )
Name
Attributes
Operations
OO Relationships
Aggregation
Composition
OO Relationships: Generalization
Supertype
Example:
Customer
Regular
Customer
Subtype1
Loyalty
Customer
Subtype2
or:
Customer
- Generalization expresses a
parent/child relationship among related
classes.
- Used for abstracting details in several
layers
Regular
Customer
Loyalty
Customer
OO Relationships: Association
University
Person
0..1
employer
*
teacher
Role
Multiplicity
Symbol
Meaning
0..1
Zero or one
M..N
0..*
1..*
Role
A given university groups many people;
some act as students, others as teachers.
A given student belongs to a single
university; a given teacher may or may not
be working for the university at a particular
time.
Class Diagram
Name
Order
Attributes
Operations
-dateReceived
-isPrepaid
-number :String
-price : Money
*
Association
-name
-address
+creditRating() : String()
{if Order.customer.creditRating is
"poor", then Order.isPrepaid must
be true }
(inside braces{}}
Generalization
Corporate Customer
Personal Customer
-contactName
-creditRating
-creditLimit
-creditCard#
Constraint
Multiplicity:
Many value
Customer
+dispatch()
+close()
class
Multiplicity: mandatory
+remind()
+billForMonth(Integer)
0..1
Multiplicity:
optional
*
Employee
*
OrderLine
-quantity: Integer
-price: Money
-isSatisfied: Boolean
Product
Third Edition]
*
has
Class Student {
Course enrolls[4];
}
Class Course {
Student have[];
}
4
enrolls
Course
OO Relationships: Composition
Composition: expresses a relationship among instances
of related classes. It is a specific kind of Whole-Part
relationship.
Whole Class
Class W
Class P2
Part Classes
Example
Automobile
Engine
Transmission
OO Relationships: Aggregation
Container Class
Aggregation: expresses a relationship among instances
of related classes. It is a specific kind of ContainerContainee
relationship.
Class C
AGGREGATION
Class E2
Class E1
Containee Classes
Example
Apples
Bag
Milk
Class
Reservations
Responsibility
Keep list of reserved titles
Handle reservation
Collaborators
Catalog
User session
Phone
Recipient
Picks up
Dial tone
Dial
Ring notification
Ring
Picks up
Hello
B
Synchronous
Asynchronous
Transmission
delayed
[condition] remove()
Condition
*[for each] remove()
Iteration
Self-Call
Creation
A
Create message
Object life starts at that point
Activation
Symbolized by rectangular stripes
Place on the lifeline where object
is activated.
Rectangle also denotes when
object is deactivated.
Activation bar
Deletion
Placing an X on lifeline
Objects life ends at that point Lifeline
Create
Return
X
Deletion
Sequence Diagram
User
Message
Catalog
Reservations
1: look up ()
2: title data ()
3: [not available] reserve title ()
4 : title returned ()
5: hold title ()
5 : title available ()
6 : borrow title ()
6 : remove reservation ()
start
6: remove reservation
3 : [not available] reserve title
User
Reservations
5: title available
6 : borrow title
2: title data
1: look up
4 : title returned
Catalog
5 : hold title
Shows the relationship between objects and the order of messages passed between them.
between them.
The objects are listed as rectangles and arrows indicate the messages being passed
The numbers next to the messages are called sequence numbers. They show the sequence
of the messages as they are passed between the objects.
convey the same information as sequence diagrams, but focus on object roles instead of the
time sequence.
State Diagrams
(Billing Example)
State Diagrams show the sequences of states an object goes
through during its life cycle in response to stimuli, together
with its responses and actions; an abstraction of all possible
behaviors.
End
Start
Unpaid
Invoice created
Paid
paying
Invoice destroying
State Diagrams
(Traffic light example)
Traffic Light
State
Transition
Red
Yellow
Green
Event
Start
Others (http://www.objectsbydesign.com/tools/umltools_byCompany.html )
Reference
1. UML Distilled: A Brief Guide to the Standard Object Modeling Language
Martin Fowler, Kendall Scott
2. IBM Rational
http://www-306.ibm.com/software/rational/uml/
5. http://www-inst.eecs.berkeley.edu/~cs169/