Sei sulla pagina 1di 77

Unified Modeling

Language
http://www.uml.org/
UML Overview
UML Goals
Define an easy-to-learn and expressive,
general purpose visual modeling language

Unify existing modeling notations

Incorporate industry best practices

Provide flexibility for applying within different


software engineering processes
Multiple Views
UML 2.0 Diagrams
Classification 1: UML
Diagrams
Structural Diagrams: Describe the structural
or static relationships among components.
(Class Diagram, Object Diagram,
Component Diagram,
Deployment Diagram)
Behavioral Diagrams: Describe the

behavioral or dynamic relationships among


components.
(Use case diagram, State chart diagram,
Activity diagram, sequence diagram)
Classification 2: UML
Diagrams
Structural Diagrams: Describe the structural
or static relationships among components.
(Class Diagram, Object Diagram,
Component Diagram,
Deployment Diagram)
Behavioral Diagrams: Describe the

behavioral or dynamic relationships among


components.
(Use case diagram, State chart diagram,
Activity diagram)
Interaction Diagrams: Describe how a
group of objects collaborate in some
Classification 3: UML
Diagrams
Structural Diagrams: Describe the structural
or static relationships among components.
(Class Diagram, Object Diagram)
Behavioral Diagrams: Describe the behavioral

or dynamic relationships among components.


(Use case diagram, State chart diagram,
Activity diagram, Communication diagram,
Interaction overview diagram, sequence
diagram)
Implementaion Diagrams: Describe the
different elements required for implementing
a system
Structural Diagrams
Object Diagrams Show run-time
relationships between object instances.

Class Diagrams show the classes and their


relationships (inheritance, aggregation,
association)

Package Diagrams modularize the model


description

Composite Structure define the internal


structure of classes and components
Structural Diagrams
Component Diagrams decompose the
system into components, show their
interfaces, dependencies and connections.

Deployment Diagrams map components to


the hardware execution environments.
Behavioral Diagrams
Use Case Diagrams Interaction scenarios
between system and its environment/users.

Activity Diagrams Flowcharts to model


high level logic and business processes.

State Machine Diagrams Model run-time


states and the events that produce
transitions between states.
Behavioral Diagrams
Communication Diagrams Show the
interactions between a set of elements

Sequence Diagrams Show the


interactions between a set of elements
using swim-lanes

Interaction Overview Diagrams Activity +


Sequence
(connect together multiple diagrams)

Timing Diagrams State + Sequence


Class Diagrams
Classes
Attributes and Operations
Association and Multiplicity
Aggregation and
Compositions
Aggregation and
Compositions
Aggregation is a special case of association.
- A directional association between objects.
- When an object has-a another object,
then you have got an aggregation between
them.
- Direction between them specified which
object contains the other object.
- Aggregation is also called a Has-a
relationship.
Aggregation and
Compositions
Composition is a special case of aggregation.
- In a more specific manner, a restricted
aggregation is called composition.
- When an object contains the other object,
if the contained object cannot exist without
the existence of container object, then it is
called composition.

Example: A class contains students.


A student cannot exist without a
class.
Inheritance
UML Example for Displaying
Specialization / Generalization
Exercise: Model the followings in UML
class diagrams
Supplier supply products.
Customer has a savings account.
University offers degrees.

Employees work on projects.

A teacher teaches courses.

A drinker likes many beverages and


beverage may like by many drinkers
A drinker has only one favorite beverage
and beverage may favorite of many
Exercise: Draw UML class diagram
Exercise
Exercise

Employee records needed to be updated.


Example: UML class
diagram
UML Diagrams (contd.)
Use Case Diagrams
Describe WHAT the system will do at a
high-level
Gather design requirements of a
systems.
As the system is analyzed to gather its
functionalities, uses cases are prepared
and actors identified.
Easy to understand, hence can use as a
good tool to communicate with users
and developers explain what the system
is intended to do.
Use Case Diagram (contd.)
Components of a Use Case Diagram
- Use case: Specific task that system
performs.
- Actor: An external entity who is
interacting with the system (User roles,
external systems, devices).
- Include (composition): How
Withdrawal
one use case
Card Identification
can be decomposed into one or more
other use cases.
<<include>>
Get Approval Modify Order
- Extend: One use case may be used to
extend the behavior of another
Use Case Diagram
Notation
Example: Use Case
Diagram <<exclude
>>

<<exclude
>>
Identifying Actors
System Boundary
Association

Ananda
Dependency - Include

Ananda
Identifying Use Cases
Example: Restaurant

External Business View of a


Restaurant
Example: Restaurant

Internal Business View of a


Restaurant
Example: Online Public Access
Catalog
Customers of the
library can search
library catalog
online to locate
various resources
(books, periodicals,
audio ).
customers may
reserve or renew
item, provide
feedback, and
manage their
Example: Point of Sales Terminal

Checkout use case


involves Customer,
Clerk and Credit
Payment Service actors.

Checkout use case


includes scanning
items, calculating total
and taxes, payment use
cases.
Example: Point of Sales Terminal
Payment use case is
represented using
generalization
relationship.

Only one specific type of


payment is accepted -
either by cash, or by
credit, debit, or with
check.
An alternative to such
representation could be to use
include relationship,
and accept several forms of
payment from the same client
Example: Online Shopping
A web customer uses some web site to
make purchases online. In order to do so
customer first searches (view) for the
items she wants to buy and subsequently
payment is done. The client can register
on the web site, for example to get some
coupons or be invited to private sales.
Example: Online Shopping
Three top level
use cases are View
Items, Make Purchase
and Client Register.
View Items use case
could be used by
customer as top level
use case if customer
only wants to find and
see some products.
This use case could also
be used as a part of
Example: Online Shopping

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 .

Customer may search for items


Browse catalog
View items recommended for him/her

All these use cases are extending use cases


as they provide some optional functions
allowing customer to find item.
Example: Online Shopping
Customer
Authentication use
case is included in
View
Recommended
Items and Add to
Wish List because
both require customer
to be authenticated.
At the same time,
item could be added
to the shopping cart
Example: Online Shopping
Example: Online Shopping
Checkout use case includes several required
uses cases.
Web customer should be authenticated
- Through user login page
- User authentication cookie ("Remember
me")
- Single Sign-On (SSO).
Web site authentication service is used in all
these use cases, while SSO also requires
participation of external identity provider.
Example: Online Shopping
Checkout use case also includes
Payment use case which could be done
either by using credit card and external
credit payment service or with
PayPal
Sequence Diagrams
Represent interactions between various
objects in the sequential order.
An important characteristic of a sequence
diagram is that it is time dependent.
Useful to communicate:
- Can be used as a requirements document
to communicate requirements for a future
system.
- Analysts can take use cases to the next
level by refining them into one or more
sequence diagrams.
Sequence Diagrams
Illustrates how objects interacts with
each other.
Emphasizes time ordering of
messages.
Can model simple sequential flow,
branching, iteration, recursion and
concurrency.
Sequence Diagrams

(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

dashed arrow back indicates return


different arrowheads for normal / concurrent
(asynchronous) methods

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

A simple sequence diagram describing how the


customer interacts with the set-top box (STB)
for ordering and watching a movie using IPTV
Example
First, the customer sends the message
Order(Movie_ID) to the STB, specifying the
desired movie.

The STB then replies with the receipt


message,
ProcessingOrder()

Starting to play the requested movie.


Object send a message to
itself

system object calling its


determineAvailableReports
method.
A Sequence Diagram
X-Axis (objects)

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)

The word "alt" is placed inside the frame's


namebox.
Combined fragments
(Options)
An option is used to model a simple
"if then" statement (i.e., if rains
then carry the umbrella).
Combined fragments
(Options)
Combined fragments (loops)
Iteration (loops)
The message is sent many times to
possibly multiple receiver
objects(model a repetitive
sequences).
syntax: * [ [ expression ] ]
message-label
Combined fragments
(loops)
Iteration examples:

:Driver :Bus

*[until full] insert()

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

getBasePrice Self call

Message

getDiscountInf
o

calculateDisco
unts

Potrebbero piacerti anche