UML Class & Use Case Diagrams
UML Class & Use Case Diagrams
Language
http://www.uml.org/
UML Overview
UML Goals
Define an easy-to-learn and expressive,
general purpose visual modeling language
<<exclude
>>
Identifying Actors
System Boundary
Association
Ananda
Dependency - Include
Ananda
Identifying Use Cases
Example: Restaurant
Make purchase is
decomposed in to View
Item and Check out
(include payment).
Example: Online Shopping
View Items use case is extended by several
optional use cases .
(contd.)
Basic Concepts
- Objects: The entities who are exchanging
massages.
- Lifeline: The lifeline represents the
existence of an object over time.
(Time between creation and
deletion)
-
Sequence Diagrams
(contd.)
Basic Concepts
- Messages: The objects exchange
messages (e.g. Operation call)
Shown as an arrow between their lifelines
The arrow originates at the sender and ends
at the receiver
Sequence Diagrams
(contd.)
message (method call) indicated by horizontal
arrow to other object
write message name and arguments above arrow
53
Sequence Diagrams
(contd.)
Activations: The white rectangles on a lifeline
are called activations and indicate that an
object is sending /responding a message.
(Activation boxes represent the time an object
needs to complete a task.)
Example 1
The analyst
object is calling
the system
object's
getAvailableRe
ports method.
The message that is Return messages
being sent to the are optional,
receiving object include when a
represents an value is returned.
operation/method that the
Example 2
member: :Book
book:Book
LibraryMember Copy
borrow(book) Object
Life Line
Y-Axis (time)
ok = mayBorrow()
message
Activation
[ok] borrow(member) box
setTaken(member)
condition
Sequence Diagrams 59
Sequence Diagrams
(contd.)
Synchronous message: (Closed end
arrow) A synchronous message is used
when the sender waits until the receiver
has finished processing the message, only
then does the caller continue.
:A :B
doYouUnderstand()
Caller
Blocke yes
d Sequence Diagrams 60
Sequence Diagrams
(contd.)
Asynchronous messages: (Open end
arrow) The sender does not wait for the
receiver to finish processing the message,
it continues immediately.
Sequence Diagrams
(contd.)
Creation and destruction
- Objects that exist at the start of an
interaction are placed at the top of the
diagram.
- Any object that are created during the
interaction are placed further down the
- Adiagram,
object's at their extends
lifeline time of creation.
as long as the
object exists.
- If the object is destroyed during the
interaction, the lifeline ends at that point in
time with a big cross
- The order of messages are read from top to
Sequence Diagrams
(contd.)
Basic Concepts
Time
line
Guard: Control information
Condition
syntax: [ expression ] message-
label
The message is sent only if the
[ok] borrow(member)
condition is true
Example:
Guard: Control information
Guard
Combined fragments
(alternatives, options, and
loops)
Alternatives
- Alternatives are used to select a mutually
exclusive choice between two or more
message sequences.
- Alternatives allow the modeling of the
classic "if then else" logic
- A combined fragment is used to group
sets of messages together to show
conditional flow in a sequence diagrams
Combined fragments
(Alternatives)
:Driver :Bus
The syntax
of
expressions
is not a
standard
Combined fragments
(loops)
Combined fragments
(loops)
Loop
Exercise: Look up item availability
A customer needs check for an availability
of product from a shop. The customer
provides the catalog#, product id and
quantity. Once the product details are
obtained inventory has to be checked for
availability of products. Then the system
returns the details of the product to the
customer. You may assume products are
arrange in different catalogs and within a
catalog you may find different products.
Solution: Look up item availability
Exercise
We have an order and are going to invoke a
command on it to calculate its price. To do
that, the order needs to look at all the line
items on the order and determine their
prices, which are based on the pricing rules
of the order lines products. Having done
that for all the line items, the order then
needs to compute an overall discount,
which is based on rules tied to the
customer.
Solution
anOrder anOrderLi aProduct aCustomer
ne
calculatePric getQuantity
e
getProduct Participa Lifeline
nt
Found aProduct
message Activatio
getPricingDet Return n
ails
Message
getDiscountInf
o
calculateDisco
unts