E N D
Interaction Models (4) Sequence Diagrams
Scenarios • A scenario is a sequence of events that occurs during the execution of a system, such as for a use case. • The scope of a scenario can vary: • It may include all events in the system • Or it may include only those events impinging on or generated by certain objects of the system. • A scenario can be: • A historical record of executing an actual system • Or a thought experiment of executing a proposed system • A scenario can be displayed as a list of text statements
Sequence Diagrams • A text format is convenient for writing but it does not show clearly the sender or receiver of a message, specially when there are more than two objects. • A sequence diagram shows the participants in an interaction and the sequence of messages among them. • A sequence diagram shows the interaction of a system with its actors to perform all or part of a use case. • A sequence diagram may also show the interaction between objects (during a use case realization)
Guidelines for sequence models • Prepare at least one scenario per use case: • Steps in the scenario should be logical commands. Not individual button clicks (during design/coding). • Start with the simplest mainline interaction: no repetitions, one main activity and typical values for parameters. • If there are different mainline interactions write a scenario for each one.
Guidelines for sequence models • Abstract the scenario into sequence diagrams: • The sequence diagram clearly show the contribution of each actor. • It is important to separate the contribution of each actor before to organizing behavior about objects. • Divide complex interactions: • Break large interactions into their constituent tasks and prepare a sequence diagram for each of them. • Prepare a sequence diagram for each error condition: • Show the system response to the error condition
Procedural Sequence Models • The UML has elaborations for sequence diagrams to show procedural calls. • Sequence Diagrams with passive objects: • In procedural approach, objects are passive. They don’t have their own threads of control. • A passive object is not activated until it has been called. • Once the execution of an operation completes returns to the caller the object becomes inactive. • The UML shows the period of time for an object’s execution as a thin rectangle. • The period of time when the object exists but is not active is shown as a dashed line.
Procedural Sequence Models • Sequence diagrams with transients objects:
Procedural Sequence Models • ObjectA is active : its activation rectangle spans the entire time shown in the diagram • ObjectB is passive during the entire time shown on the diagram • During part of the time ObjectB it perfors a recursive operation shown by the doubled activation rectangle. • ObjectC is created and destroyed during the time shown in the diagram.