You are on page 1of 20

Sequence Diagrams

Scenarios
• A scenario is a sequence of events that occurs during one
particular execution of a system.

• A scenario can include all events in the system or can only


include these events that are generated by a certain object in
that system.

• A scenario can be a historical record of executing or


simulating the execution of a system or an object.
Sequence diagrams
• Generally show the sequence of events that
occur.
• Illustrates the objects that participate in a use
case and the messages that pass between them
over time for one use case

• In design, it used to distribute use case behavior


to classes
Sequence Diagram Syntax
1. AN ACTOR

An Object : a Class
2. AN OBJECT

usually dashed line that represents the lifetime of the object associated with
3. A LIFELINE it. At the top end of the line is the head of the lifeline, a rectangle which
contains an expression in the form roleName:Class

4. A FOCUS OF CONTROL

5.
In a sequence diagram, a message is depicted as
a Message() an arrow from the sender to the receiver.
A MESSAGE

6. OBJECT DESTRUCTION x
General Sequence Diagram
• It is composed of a
diagram frame:
1) with an identifier name
order process

2) the individual
participants (classes) in
client order inventory
the form of “lifeline”
composed of:
• A rectangle depicting
create
the participating
object locate item
• A dotted line that
extends for the time
period of the
interaction
3) messages to
communicate among the
participants
Example of Analysis Level UML Sequence Diagram
Basic Structure of UML sequence Diagram

Central contrl
In case (b), the student registers
In case (a), the registration is via e- with the professor personally and
mail, that is, asynchronous. The the communication is therefore
student does not explicitly wait for the synchronous.
receipt of the confirmation message. The student waits until receiving
a response message.
• ALT : operator has at least two operands. Each operand represents an
alternative path in the execution, which corresponds approximately to
multiple cases in programming languages, for example, the switch
statement
• OPT : the opt operator thus represents an interaction sequence whose
actual execution at runtime is dependent on the guard. In a programming
language, this operator would be specified as an if statement without an else
branch
• LOOP: the loop fragment to express that a sequence is to be executed
repeatedly The keyword loop is followed by an optional specification of the
number of iterations of the loop
UML Sequence Diagram
(Coursera course video)
• https://www.youtube.com/watch?v=7JyUQ
L0KQ4w&ab_channel=PhamThuyHang
Sequence Diagram
The Connection between a
Class Diagram and a
Sequence Diagram
Consider the Class diagram
• The student administration system has
direct access to all students and courses.
• The system knows the registration data
for students and courses that is stored in the class
Registration.
• To do this, the method newRegistration
of the class StudentAdminSystem must be called

• create a new object of the type Registration


and call the init operation that sets the student and
the course for the registration object.
• Establish the connection between the registration
and the course
• We do this by calling the method setRegistration
The resulting sequence diagram is shown below
Exercise

To give an exam, an instructor


first notifies the students of the
exam date and the material to be
covered. He/she then prepares the
exam paper, gets its enough
copies and hands it out to students
on the designated time and
location. The students write their
answers to exam questions and
hand in their papers to the
instructor. The instructor then
gives the exam papers to the TAs,
along with sample solutions to
each question, and gets them to
mark it. He/She then records all
marks and returns the papers to
the students.
Exercise

Develop a sequence
diagram showing the
interaction involved
when a student registers
for a course in a
university. Courses may
have limited enrolment,
so the registration
process must include
checks that places are
available.
Assume that student
accesses an electronic
course catalog to find out
about available courses
Example Create a UML Sequence Diagram for the Use
Case “Check out shopping cart”
1. The Customer presses the “Check out”
button
2. The system shows the contents of the
shopping cart and asks for the
Shipping Address
3. The Customer enters the Shipping
Address
4. The system asks for credit card
information
5. The Customer enters credit card
information
6. The system sends the payment
information to the Bank system
7. The Bank system returns transaction
OK
8. The System creates the Order
9. The System sends a notification to the
Deliver man
10. The System shows the Confirmation of
Place Order page

You might also like