Object-Oriented Design Lecture 13: Use Case Realizations Sharif - - PowerPoint PPT Presentation

object oriented design
SMART_READER_LITE
LIVE PREVIEW

Object-Oriented Design Lecture 13: Use Case Realizations Sharif - - PowerPoint PPT Presentation

Object-Oriented Design Lecture 13: Use Case Realizations Sharif University of Technology 1 Department of Computer Engineering Analysis Workflow: Analyze a Use Case The analysis workflow consists of the following activities:


slide-1
SLIDE 1

Department of Computer Engineering

Object-Oriented Design

Lecture 13: Use Case Realizations

Sharif University of Technology 1

slide-2
SLIDE 2

Analysis Workflow: Analyze a Use Case

  • The analysis workflow consists of the following activities:
  • Architectural analysis
  • Analyze a use case
  • Outputs:
  • analysis classes
  • use case realizations
  • Analyze a class
  • Analyze a package

Sharif University of Technology 2

slide-3
SLIDE 3

Use Case Realizations

  • Use case realizations show how instances of analysis classes

interact to realize the functional requirements specified by a use case.

  • Each use case realization realizes exactly one use case.
  • Use case realizations consist of:
  • analysis class diagrams - these should "tell a story" about one (or more)

use cases;

  • interaction diagrams - these demonstrate how objects interact to realize

the use case behavior;

  • special requirements - you always uncover new requirements during use

case realization and you need to record these;

  • use case refinement - you may need to change a use case as you begin to

realize it.

Sharif University of Technology 3

slide-4
SLIDE 4

Lifelines

  • A lifeline represents a participant in an interaction - how an instance of a

classifier participates in the interaction.

  • Each lifeline has an optional name, a type, and an optional selector.
  • Each lifeline is drawn with the same icon as its type.
  • Underline the name, type, and selector to show actual instances .

Sharif University of Technology 4

slide-5
SLIDE 5

Messages

  • A message represents a specific kind of communication between two lifelines

in an interaction.

Sharif University of Technology 5

slide-6
SLIDE 6

Interaction Diagrams

  • Sequence diagrams - emphasize time-ordered sequence of

message sends.

  • Communication diagrams - emphasize structural relationships

between objects.

  • Interaction overview diagrams - emphasize relationships

between interactions.

  • Timing diagrams - emphasize real-time aspects of interactions.

Sharif University of Technology 6

slide-7
SLIDE 7

Sequence vs. Communication diagram

  • Sequence Diagrams: show object interactions arranged in time

sequence, vertically

  • Communication Diagrams: show object interactions arranged as a

flow of objects and their links to each other, numerically

  • Semantically equivalent, structurally different
  • Sequence diagram emphasize time ordering
  • Communication diagrams make object linkages explicit

Sharif University of Technology 7

slide-8
SLIDE 8

Sequence Diagrams: General Notation

  • Time runs top to bottom.
  • Lifelines run left to right:
  • lifelines have dashed vertical tails that indicate the duration of the lifeline;
  • lifelines may have activations to indicate when the lifeline has focus of

control;

  • rganize lifelines to minimize the number of crossing lines.
  • Place explanatory scripts down the left-hand side of the sequence

diagram.

  • State invariants - place state symbols on the lifeline at the appropriate

points.

  • Constraints - place constraints in {} on or near lifelines.

Sharif University of Technology 8

slide-9
SLIDE 9

9

UML sequence diagrams

  • sequence diagram: an "interaction diagram" that models a

single scenario executing in the system

  • perhaps 2nd most used UML diagram (behind class diagram)
  • relation of UML diagrams to others:
  • CRC cards -> class diagram
  • use cases -> sequence diagrams
  • the axes in a sequence diagram:
  • horizontal: which object/participant is acting
  • vertical: time (down -> forward in time)
slide-10
SLIDE 10

Sequence Diagrams: Realization Example 1

Sharif University of Technology 12

slide-11
SLIDE 11

Sequence Diagrams: Realization Example 2

Sharif University of Technology 13

slide-12
SLIDE 12

Sequence Diagrams: Realization Example 3

Use Case

Sharif University of Technology 14

slide-13
SLIDE 13

Sequence Diagrams: Realization Example 3

Sequence Diagram

Sharif University of Technology 15

slide-14
SLIDE 14

Combined Fragments

  • Combined fragments - areas within a sequence diagram with

different behavior.

  • The operator defines how its operands execute.
  • The guard condition defines whether its operand executes.
  • The operand contains the behavior.

Sharif University of Technology 16

slide-15
SLIDE 15

Combined Fragments: Operators – opt and alt

  • pt - there is a single operand that executes if the condition is true (like if ...

then).

  • alt - the operand whose condition is true is executed.

Sharif University of Technology 17

slide-16
SLIDE 16

Combined Fragments: Operators – opt and alt

Sharif University of Technology 18

slide-17
SLIDE 17

Combined Fragments: Operators – loop and break

  • loop - loop min, max [condition]
  • loop or loop * - loop forever;
  • loop n, m - loop (m – n + 1) times;
  • loop [ booleanExpression ] - loop while booleanExpression is true;
  • loop 1, * [ booleanExpression ] - loop once then loop while

booleanExpression is true;

  • loop [for each object in collectionOfObjects] - execute the body of the

loop once for each object in the collection;

  • loop [for each object in className] - execute the body of the loop once for

each object of the class.

  • break - if the guard condition is true, the operand is executed, not

the rest of the enclosing interaction.

Sharif University of Technology 19

slide-18
SLIDE 18

Combined Fragments: Operators – loop and break

Syntax

Sharif University of Technology 20

slide-19
SLIDE 19

Combined Fragments: Operators – loop and break

Example

Sharif University of Technology 21

slide-20
SLIDE 20

Combined Fragments: Operators – Other

  • ref - the combined fragment refers to another interaction.
  • par - all operands execute in parallel.
  • critical - the operand executes atomically without interruption.
  • seq - operands execute in parallel subject to the following constraint: events

arriving on the same lifeline from different operands occur in the same sequence as the operands occur.

  • strict - the operands execute in strict sequence.
  • neg - the operand shows invalid interactions.
  • ignore -lists messages that are intentionally omitted from the interaction.
  • consider -lists messages that are intentionally included in the interaction.
  • assert - the operand is the only valid behavior at that point in the interaction.

Sharif University of Technology 22

slide-21
SLIDE 21

23

Example sequence diagram

sd Example loop StoreFront Cart Inventory AddItem ReserveItem PlaceItemInOrder Checkout ProcessOrder ConfirmOrder

slide-22
SLIDE 22

24

(De)centralized system control

  • What can you say about the control flow of each of

the following systems?

  • centralized?
  • distributed?
slide-23
SLIDE 23

Communication (aka Collaboration) Diagrams

  • Communication diagrams - emphasize the structural aspects of an interaction:
  • lifelines are connected by links;
  • messages have a sequence number - they are numbered hierarchically according to

the nesting of the focus of control.

Sharif University of Technology 27

slide-24
SLIDE 24

Communication (aka Collaboration) Diagrams

  • Objects are rectangular icons
  • e.g., Order Entry Window, Order, etc.
  • Messages are arrows between icons
  • e.g., prepare()
  • Numbers on messages indicate sequence
  • Also spatial layout helps show flow
  • Which do you prefer: sequence or communication?
  • Fowler doesn’t use communication diagrams
  • Show flow clearly, but awkward modeling alternatives

Sharif University of Technology 28

slide-25
SLIDE 25

Iteration

  • Iteration - use an iteration specifier (*) and an optional iteration clause on

the message.

  • The iteration clause specifies the number of times to loop.
  • You can use natural language, pseudocode, source code, or sequence

diagram loop notation for the iteration clause.

  • Iteration over a collection of objects:
  • Denoted by showing the role name and multiplicity (>1) on the target

end of the link and prefixing the message with *.

  • The message is sent to each object in turn.
  • Use the parallel iteration specifier *// to indicate that messages are

executed in parallel.

Sharif University of Technology 29

slide-26
SLIDE 26

Iteration - Example

Sharif University of Technology 30

slide-27
SLIDE 27

Branching

  • Branching - prefix messages with guard conditions. The message

executes if the guard condition is true.

  • It can be hard to show branching clearly on a communication

diagram - for complex branching, use sequence diagrams instead.

Sharif University of Technology 32

slide-28
SLIDE 28

Communication and Class Diagrams

  • Links in a communication diagram directly correlate

to associations between classes in a class diagram

slide-29
SLIDE 29

Interaction Occurrences

  • Interaction occurrences: references to another interaction.
  • The flow of the referenced interaction is included in the flow of the

referencing interaction.

  • Parameters - interaction occurrences may have parameters - use normal

parameter notation.

  • Gates - inputs and outputs of interactions:
  • a point on the sequence diagram frame that connects a message
  • utside the frame to a message with the same signature inside the

frame.

  • Use parameters when you know the source and destination of all

messages - use gates when you don't.

Sharif University of Technology 36

slide-30
SLIDE 30

Interaction Occurrences – Example

Use Case and Class Diagram

Sharif University of Technology 37

slide-31
SLIDE 31

Interaction Occurrences – Example

SDs

Sharif University of Technology 38

slide-32
SLIDE 32

Interaction Occurrences – Parameters

Sharif University of Technology 39

slide-33
SLIDE 33

Interaction Occurrences – Gates

Sharif University of Technology 40

slide-34
SLIDE 34

Communication Diagram Overview

Sharif University of Technology 41

slide-35
SLIDE 35

Sequence Diagram Overview

Sharif University of Technology 42

slide-36
SLIDE 36

Reference

  • Arlow, J., Neustadt, I., UML 2 and the Unified Process: Practical Object-

Oriented Analysis and Design, 2nd Ed. Addison-Wesley, 2005.

Sharif University of Technology 43