Lecture 5 sequence diagram
-
Upload
ramakant-soni -
Category
Education
-
view
178 -
download
3
Transcript of Lecture 5 sequence diagram
Ramakant SoniAssistant Professor
Dept. of Computer Science
B K Birla Institute of Engineering & Technology, Pilani, India
2nd December 2014
14h 00-17h 00
Ramakant Soni @ EISTI Cergy 12/2/2014
1
12/2/2014Ramakant Soni @ EISTI Cergy 2
Sequence Diagram Definition
A Sequence diagram is an interaction diagram that
shows
-- how the objects and classes involved in the scenario
operate with one another.
-- the sequence of messages exchanged .
12/2/2014Ramakant Soni @ EISTI Cergy 3
Its Significance
An organization's technical staff can find sequence
diagrams useful in documenting how a future system
should behave.
During the design phase, architects and developers
can use the diagram to force out the system's object
interactions, thus fleshing out overall system design.
12/2/2014Ramakant Soni @ EISTI Cergy 4
Its Use
One of the primary uses of sequence diagrams is in the
transition from requirements expressed as use cases to
the next level of refinement.
Use cases are often refined into one or more sequence
diagrams.
In addition to their use in designing new systems,
sequence diagrams can be used to document how
objects in an existing system currently interact.
This documentation is very useful when transitioning a
system to another person or organization.
12/2/2014Ramakant Soni @ EISTI Cergy 5
Targets
Objects as well as classes can be targets which means
that messages can be sent to them.
A target is displayed as a rectangle with some text in it.
Below the target, its lifeline(vertical dashed line) extends
for as long as the target exists.
Target
Lifeline
12/2/2014Ramakant Soni @ EISTI Cergy 6
Multi Object
To show how a client interacts with the elements of a
collection, you can use a multi-object.
Its basic notation is:
12/2/2014Ramakant Soni @ EISTI Cergy 7
Class
The basic notation for a class is:
Only class messages (e.g. shared or static methods in some
programming languages) can be sent to a class. Generally text of
a class is not underlined, which is how you can distinguish it from an
object.
12/2/2014Ramakant Soni @ EISTI Cergy 8
Messages
Message is a named element that defines one specific
kind of communication between lifelines of an
interaction.
The message specifies not only the kind of
communication, but also the sender and the receiver.
12/2/2014Ramakant Soni @ EISTI Cergy 9
Message Notation
A message is represented by an arrow between the life
lines of two objects.
-Self calls are also allowed
-The time required by the receiver object to process
the message is denoted by an activation-box.
A message is labeled at minimum with the message
name.
12/2/2014Ramakant Soni @ EISTI Cergy 11
Call Message
Call message is a kind of message that represents an
invocation of operation of target lifeline.
Its type:
- Synchronous Call
- Asynchronous Call
12/2/2014Ramakant Soni @ EISTI Cergy 12
Synchronous Call
Synchronous call typically represents operation call -
send message and suspend execution while waiting for
response. Synchronous call messages are shown with
filled arrow head.
12/2/2014Ramakant Soni @ EISTI Cergy 13
Asynchronous Call- Send
Asynchronous call - send message and proceed
immediately without waiting for return value.
Asynchronous messages have an open arrow head.
12/2/2014Ramakant Soni @ EISTI Cergy 14
Create Message
Create message is sent to a lifeline to create itself. It is
shown as a dashed line with open arrowhead.
12/2/2014Ramakant Soni @ EISTI Cergy 15
Destroy Message
Delete message is sent to terminate another lifeline. The
lifeline usually ends with a cross in the form of an X at
the bottom denoting destruction occurrence.
12/2/2014Ramakant Soni @ EISTI Cergy 16
Return Message
Reply message to an operation call is shown as a
dashed line with open arrow head (looks similar to
creation message).
12/2/2014Ramakant Soni @ EISTI Cergy 17
Self Message
A self message can represent a
recursive call of an operation, or one
method calling another method
belonging to the same object.
It is shown as creating a nested focus
of control in the lifeline’s execution
occurrence.
12/2/2014Ramakant Soni @ EISTI Cergy 18
Combined Fragments
A combined fragment is one or more processing
sequence enclosed in a frame and executed under
specific named circumstances.
The fragments available are:
alt- Alternative fragment models if…then…else constructs. Only one
sequence occurs on any occasion.
opt- Optional. Encloses a sequence that might or might not happen.
You can specify, in the guard, the condition under which it
occurs.
break- If this fragment is executed, the rest of the sequence is
abandoned.
Par- Parallel fragment denotes concurrent processing.
12/2/2014Ramakant Soni @ EISTI Cergy 19
fragments
Seq - There are two or more operand fragments. Messages
involving the same lifeline must occur in the order of the fragments.
Where they do not involve the same lifelines, messages from
different fragments may be interleaved in parallel.
strict - Strict sequencing fragment encloses a series of messages
which must occur in the given order.
neg - Negative fragment encloses an invalid series of messages.
loop - Loop fragment encloses a series of messages which are
repeated.
Loop combined fragments have the properties Min and Max,
which indicate the minimum and maximum number of times thatthe fragment can be repeated. The default is no restriction.
12/2/2014Ramakant Soni @ EISTI Cergy 20
fragments
ignore - Ignore fragment declares a message or message to be of
no interest if it appears in the current context.
consider - Consider fragment is in effect the opposite of the ignorefragment: any message not included in the consider fragment
should be ignored.
assert - Assertion fragment designates that any sequence not
shown as an operand of the assertion is invalid.
12/2/2014Ramakant Soni @ EISTI Cergy 24
Interaction Operands
Interaction operand is a named element representing
the most general interaction unit. Each interaction
fragment is conceptually like an interaction by itself.
Every combined fragment contains at least one
interaction operand, which can contain messages,
interaction uses, and smaller combined fragments.
12/2/2014Ramakant Soni @ EISTI Cergy 27
Example: Facebook Authentication
Scenario:- Facebook uses OAuth 2.0 protocol framework which enables
web application (called "client"), which is usually not the FB resource
owner but is acting on the FB user's behalf, to request access to
resources controlled by the FB user and hosted by the FB server. Instead
of using the FB user credentials to access protected resources, the web
application obtains an access token.
Web application should be registered by Facebook to have an
application ID (client_id) and secret (client_secret). When request to
some protected Facebook resources is received, web browser ("user
agent") is redirected to Facebook's authorization server with application
ID and the URL the user should be redirected back to after the
authorization process.
User receives back Request for Permission form. If the user authorizes the
application to get his/her data, Facebook authorization server redirects
back to the URI that was specified before together with authorization
code ("verification string"). The authorization code can be exchanged
by web application for an OAuth access token.
12/2/2014Ramakant Soni @ EISTI Cergy 28
If web application obtains the access token for a FB user, it can
perform authorized requests on behalf of that FB user by including the
access token in the Facebook Graph API requests. If the user did not
authorize web application, Facebook issues redirect request to the URI
specified before, and adds the error_reason parameter to notify the
web application that authorization request was denied.
12/2/2014Ramakant Soni @ EISTI Cergy 33
Exercise:
To generate sequence diagram using use case
Steps:-
1. Designate actors and business system—Who is taking part?
2. Designate initiators—Who starts interactions?
3. Describe the message exchange between actors and business
system—Which messages are being exchanged?
4. Identify the course of interactions—What is the order?
5. Insert additional information—What else is important?
6. Verify the view—Is everything correct?
12/2/2014Ramakant Soni @ EISTI Cergy 34
Exercise: Home heating system
Home Owner
Power Up
Power Down
Change Temp.
Home Heating
Adjust Temp
Temp. High
Temp. Low
«includes»
«includes»
«includes»
«includes»
12/2/2014Ramakant Soni @ EISTI Cergy 37
References:
[1] http://www.uml-diagrams.org/
[2] http://www.wikipedia.com/UML%diagrams
[3] http://staruml.sourceforge.net/docs/user-guide%28en%29/ch05_3.html
[4] http://www.ibm.com/developerworks/rational/library/3101. html
[5] http://www.uml-diagrams.org/sequence-diagrams-examples.html