170 likes | 190 Views
This chapter discusses the use of sequence diagrams in software engineering to model the interactions between actors and objects within a system. It explains how sequence diagrams are used to detail the sequence of messages exchanged between objects and actors, and how to create effective sequence diagrams for use case scenarios. The chapter also covers different types of objects, message formats, activation, and loop structures in sequence diagrams.
E N D
Chapter 9: Sequence DiagramsChapter 5 in Software Engineering Book
An InteractionModel • Used to model the interactionsbetweenthe actors and the objects within a system. • The objects and actors involved are listed along the top of the diagram, with a dotted line drawn vertically from these. • Interactions between objects are indicated by annotated arrows. • Detail how operations are carried out • Dynamic Diagrams • Organizedaccording to time • The time progresses as you go down the page • The objects involved in the operation are listed from left to right according to when they take part in the message sequence. • Create a sequence diagram for each use case scenario Sequence diagrams: An Interaction Model
actors and objects Object lifeline Sequence Diagram (make a phone call)
Sequence diagrams show how instance exchangemessages. • An instance can be: • An object, not a class • An actor • Types of objects in a diagram • interface object • entity object • control object • Messages ( ) can be Simple like: • One object sends a message to a passive object • The sender does not care what happens to the message • Messages can be Return messages ( ) Results of procedure calls Sequence Diagrams
Sequence Diagrams • Activation: thick boxoverobject'slifeline; drawn when object's method is on the stack • either that object is running its code, or it is on the stack waiting for another object's method to finish • nest activations to indicate recursion
Sequence Diagrams • Messages have a specific format Sequence Number. Return value := MessageName(Arguments) [Condition] *[iteration] [Condition] Sequence Number. Return value := MessageName(Arguments)
Messages can be Constructors, the message creates the recipient Sequence Diagrams
Sequence Diagrams • Messages can be Destructors, the message destroys the recipient.
Sequence Diagrams A Found message whose Sender will not be specified
Sequence Diagrams FoundMessage Message to “self” or “this”
Sequence Diagrams • frame: box around part of diagram to indicate if or loop • if -> (opt) [condition] • if/else -> (alt) [condition], separated by horizontal dashed line • loop -> (loop) [condition or items to loop over]
loop If/else If
:Register :ProductCatalogue Sale :ProductSpec addLineItem(itemID, quantity) 1. Spec=getSpecification(itemID) 1.1 Spec=Find(itemID) 2. makeLineItem(spec,quantity) 2.1 sli= Create(spec,quantity) :SalesLineItem 2.2 Add(sli) Creating methods from sequence diagrams
Creating methods from sequence diagrams LostMessage
Use only instances and actors • Concentrate on actions, not on instance static details • Imaging as much real-timescenarios as you can, and model them • Keep in mind that a programmer will read your design, so make it as clear as possible. • Sequence diagrams contain the same information as Collaboration diagrams, but emphasize the sequence of the messages instead of the relationships between the objects. Effective Sequence Diagrams