Object Oriented Analysis and Design Sequence Diagrams.

17
Object Oriented Analysis and Design Sequence Diagrams

Transcript of Object Oriented Analysis and Design Sequence Diagrams.

Page 1: Object Oriented Analysis and Design Sequence Diagrams.

Object Oriented Analysis and Design

Sequence Diagrams

Page 2: Object Oriented Analysis and Design Sequence Diagrams.

Contents

2

Sequence Diagrams

Page 3: Object Oriented Analysis and Design Sequence Diagrams.

Static vs. Dynamic Views of Software

3

Class diagrams show the classes which comprise a program

It does nothing to show you how to use those classes

You need Examples of how to use the classes to accomplish

a task Examples of what methods to call Examples of how to combine classes to do

something useful The sequence diagram accomplishes this by

showing the software in a dynamic state

Page 4: Object Oriented Analysis and Design Sequence Diagrams.

Uses of Sequence Diagrams

4

Each sequence diagram shows how to perform one task

Each message passed between objects is a real method call

Sequence diagrams are examples of how to use the classes to perform tasks

Page 5: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagrams

5

Sequence diagrams show how messages are sent from one object to another to accomplish a task

The sequence diagram concentrates on the time at which messages are sent

The sequence diagram makes it easier to see a sequence of interactions

Page 6: Object Oriented Analysis and Design Sequence Diagrams.

Sample Diagram

6

Page 7: Object Oriented Analysis and Design Sequence Diagrams.

Messages

7

The actions that objects perform on each other Major types of messages

Flat flow of control Procedure call Return from a Procedure call

May have optional guard conditions

Page 8: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagrams

8

Uses rectangles to represent objects Uses a dashed vertical line to represent the

lifetime of the object Uses a solid rectangle on top of the lifeline to

represent when the object is active and has the flow of control

This is called an activation bar

Page 9: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagrams

9

Object names A fully qualified object

Dan:Customer An anonymous object

:Customer

Return values Usually indicated by a dashed line going to the left

Page 10: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagrams

10

If the same method is called multiple times in an iteration, this is indicated by a guard condition beside the method

Other conditions can be placed before the method

:Customer :Order

[for each product] :addItem(product)

Page 11: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagrams

11

Page 12: Object Oriented Analysis and Design Sequence Diagrams.

Timelines

12

A sequence diagram depicts time as increasing in the downward direction

Each object is on a timeline and first appears when it is created

Later on the timeline, it sends messages to and receives messages from other objects

The timeline let’s you easily see the order in which the messages are sent and received

Page 13: Object Oriented Analysis and Design Sequence Diagrams.

Message Synchronization

13

Most messages are synchronous This means that the caller waits for the

message to complete before it continues to the next operation

If a message is asynchronous, the caller does not wait for the message to be completed before continuing to the next operation

Page 14: Object Oriented Analysis and Design Sequence Diagrams.

Message Synchronization

14

Synchronous message use a solid arrowhead

Asynchronous messages use a stick arrowhead

Page 15: Object Oriented Analysis and Design Sequence Diagrams.

Object Creation

15

Shows that an object is created in the sequence diagram

Known as a Constructor Message points directly to the object being

created as opposed to the timeline

Page 16: Object Oriented Analysis and Design Sequence Diagrams.

Object Destruction

16

Shows that an object is destroyed in the sequence diagram

Known as a Destructor Signified by an X at the end of the timeline

Page 17: Object Oriented Analysis and Design Sequence Diagrams.

Sequence Diagram Messages

17

Messages indicate method calls Can point to same object when it makes a

recursive call Can have multiple recursive arrows stacked to

indicate multiple recursion Can be slanted to indicate call takes time