0% found this document useful (0 votes)
76 views

Software Engineering Lecture - Sequence Diagram

The document discusses sequence diagrams and their use in modeling interactions between objects in a software system. It provides details on the key parts of a sequence diagram, including objects and actors listed along the top with lifelines indicating the time an object is involved in computation. Interactions are shown with annotated arrows between object lifelines. The document also provides an example of a sequence diagram modeling the process of sending an email, with objects like the user, icon bar, email page, address book, and email server.

Uploaded by

Waqar Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Software Engineering Lecture - Sequence Diagram

The document discusses sequence diagrams and their use in modeling interactions between objects in a software system. It provides details on the key parts of a sequence diagram, including objects and actors listed along the top with lifelines indicating the time an object is involved in computation. Interactions are shown with annotated arrows between object lifelines. The document also provides an example of a sequence diagram modeling the process of sending an email, with objects like the user, icon bar, email page, address book, and email server.

Uploaded by

Waqar Sheikh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

CSE291 - Introduction To Software

Engineering
(Fall 2019)

Sequence Diagrams
04/30/2020 CSE291 - Introduction to Software Engineering 2

Beginnings of a Method

Systems
Model
04/30/2020 CSE291 - Introduction to Software Engineering 3

Interaction Models

All systems involve interaction of some kind…

• This can be user interaction, which involves user inputs and outputs
• Interaction between the system being developed and other systems
• Or interaction between the components of the system

Use case modeling, which is mostly used to model interactions


between a system and external actors (users or other systems).

Sequence diagrams, which are used to model interactions between


system components, although external agents may also be included.
04/30/2020 CSE291 - Introduction to Software Engineering 4

UML Sequence Diagrams

• Sequence diagrams are used to model interactions between


the actors and the objects in a system and the interaction
between the objects themselves.

• It shows the sequence of interactions that take place during


particular use case.

• Typically used to understand the logical flow of system.


04/30/2020 CSE291 - Introduction to Software Engineering 5

Sequence Diagram Key Parts


• In a sequence diagram, objects and actors are listed along the top of
the diagram, with a dotted line drawn vertically from these.

• Interactions between objects are indicated by annotated arrows/


Labelled arrows

• The annotations on the arrows indicate the calls to the objects

• The rectangle on the dotted line indicates the life line of object
concerned (the time that object involved in computation)

• Read the sequence of interactions from top to bottom.


04/30/2020 CSE291 - Introduction to Software Engineering 6

Sequence Diagram Notation

Object1 name:classname Object 2name:classname

Actors Objects

In a sequence diagram, objects and actors are aligned along the top of
the diagram. with a dotted line drawn vertically from these.
04/30/2020 CSE291 - Introduction to Software Engineering 7

Sequence Diagram Notation


:Object 1 :Object 2
04/30/2020 CSE291 - Introduction to Software Engineering 8

Sequence Diagram Notation


:Object 1 :Object 2

The rectangle on the dotted line indicates the life line of object concerned
(Indicate when an object is performing an action)
04/30/2020 CSE291 - Introduction to Software Engineering 9

Sequence Diagram Notation


:Object 1 :Object 2

message

Interactions between objects are indicated by annotated arrows/


Labelled arrows
04/30/2020 CSE291 - Introduction to Software Engineering 10

Sequence Diagram Notation


:Object 1 :Object 2

message

message

Sequence
Vertical position signifies sequence – earlier messages appear
nearer the top.
04/30/2020 CSE291 - Introduction to Software Engineering 11

Developing Sequence Diagrams


• Identify the relevant objects involved in the computation
• Establish the role of each object
• Decide messages between objects
04/30/2020 CSE291 - Introduction to Software Engineering 12

Sequence Diagram
• Tracks a sequence of events in a scenario
• Identifies all objects involved

Objects
O1 O2 O3 O4 O5 indicates
that the
E1 event
E2 effects the
Events object
E3

E4
04/30/2020 CSE291 - Introduction to Software Engineering 13

Sequence Diagram (make a phone call)


04/30/2020 CSE291 - Introduction to Software Engineering 14

A Simpler Example - Sending an email


04/30/2020 CSE291 - Introduction to Software Engineering 15

E-mail Interface
04/30/2020 CSE291 - Introduction to Software Engineering 16

Working From a Scenario


Sending an email

1. Press “New ” email icon


2. Enter person’s name in “To” section
3. Type subject
4. Type contents
5. Press Send button
6. System looks up email address in address book
7. System submits the email to the email server
04/30/2020 CSE291 - Introduction to Software Engineering 17

Starting The Diagram


• If this is an interactive scenario, we always have an actor
driving it

: user
04/30/2020 CSE291 - Introduction to Software Engineering 18

Add Objects
The first interaction is with the icon bar, which we can treat as an
Object
: icon bar

: user
04/30/2020 CSE291 - Introduction to Software Engineering 19

Add Message
The user talks to the icon bar

: icon bar

: user
04/30/2020 CSE291 - Introduction to Software Engineering 20

Label The Communication


: icon bar

: user
click send mail

Remember that actors can only communicate with interface


objects such as screens, menus and icon bars.
04/30/2020 CSE291 - Introduction to Software Engineering 21

The icon bar has some work to do.


It creates an email page.

: icon bar : email page

: user
click send mail create

Now the user can see the email page and use it.
04/30/2020 CSE291 - Introduction to Software Engineering 22

The next three steps are filling in the details on


the email page

: icon bar : email page

: user
click send mail create

fill in to box
fill in subject box
fill in contents box
04/30/2020 CSE291 - Introduction to Software Engineering 23

The User then clicks Send


: icon bar : email page

: user
click send mail create

fill in to box
fill in subject box
fill in contents box

send
04/30/2020 CSE291 - Introduction to Software Engineering 24

Now consider how to do the sending


: icon bar : email page : address book

: user
click send mail create

fill in to box
fill in subject box
fill in contents box

send
look up email address

We can choose to get the email page to look up the email


address from an address book object
04/30/2020 CSE291 - Introduction to Software Engineering 25

: icon bar : email page : address book

: user
click send mail create

fill in to box
fill in subject box
fill in contents box

send
look up email address
04/30/2020 CSE291 - Introduction to Software Engineering 26

We can choose to get the email page to submit the email


to the email server

: icon bar : email page : address book : email server

: user
click send mail create

fill in to box
fill in subject box
fill in contents box

send
look up email address

submit email
04/30/2020 CSE291 - Introduction to Software Engineering 27

And if we think carefully, the email page always closes after


the send.
: icon bar : email page : address book : email server

: user
click send mail create

fill in to box
fill in subject box
fill in contents box

send
look up email address

submit email

close
04/30/2020 CSE291 - Introduction to Software Engineering 28

Now we go through and change the messages to


operations on the object

: icon bar : email page : address book : email server

: user
send mail( ) create

fill in to box
fill in subject box
fill in contents box

send
look up email address

submit email

close
04/30/2020 CSE291 - Introduction to Software Engineering 29

And so on, all the way through

: icon bar : email page : address book : email server

: user
send mail( ) create( )

enterTo( )
enterSubject( )
enterContents( )

send( )
getEmailAddress( )

submitEmail( )

close( )
04/30/2020 CSE291 - Introduction to Software Engineering 30

Exercise
Consider the following scenario and draw sequence diagram for
online book shop.

“Online customer can search book catalog, view description of


a selected book, add book to shopping cart, do checkout”.
04/30/2020 CSE291 - Introduction to Software Engineering 31

Sequence Fragment

• A sequence fragment is represented as a box that frames a


section of interactions between objects in a sequence
diagram.

• It is used to show complex interactions such as alternative


flows and loops in a more structured way.

• On the top left corner of the fragment sits an operator. This


– the fragment operator – specifies what sort of a fragment
it is.
04/30/2020 CSE291 - Introduction to Software Engineering 32

Alternative Fragment
• The alternative fragment is used when a choice needs to be
made between two or more message sequences. It models
the “if then else” logic.

• The alternative fragment is represented by a large rectangle


or a frame; it is specified by mentioning ‘alt’ inside the
frame’s name box

• To show two or more alternatives, the larger rectangle is


then divided using a dashed line

Each operand has a guard to test against and it is placed at


the top left corner of the operand.
04/30/2020 CSE291 - Introduction to Software Engineering 33

An alternative fragment provides several guarded alternative fragments 


04/30/2020 CSE291 - Introduction to Software Engineering 34

Option Fragment
• The option fragment is used to indicate a sequence that will
only occur under a certain condition, otherwise, the
sequence won’t occur. It models the “if then” statement.

• Similar to the alternative fragment, the option fragment is


also represented with a rectangular frame where ‘opt’ is
placed inside the name box.

• Unlike the alternative fragment, an option fragment is not


divided into two or more operands. Option’s guard is placed
at the top left corner.
04/30/2020 CSE291 - Introduction to Software Engineering 35

An optional fragment is only executed if some guard condition is


true
04/30/2020 CSE291 - Introduction to Software Engineering 36

Home Task

• Loop Fragment
• Reference fragment

You might also like