Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved Design Model Interaction diagram.

Similar presentations


Presentation on theme: "Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved Design Model Interaction diagram."— Presentation transcript:

1 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved Design Model Interaction diagram

2 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 2 Elaboration Iteration 1 On to Object Design (OOD)

3 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 3 Analysis and Design

4 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 4 Object-oriented Analysis and Design n Object-oriented analysis – What are the domain objects? Described in a domain object model n Object-oriented design – Describing the software solution in terms of collaborating objects, with responsibilities.

5 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 5 Transition to Design n During requirements and analysis work, we – “Do the right thing” – Understand the domain – Clarify and record the constraints and requirements – Essentially ignore thinking about the design, and focus on understanding the problem. –... n During design, we – “Do the thing right” – Create a software (and hardware) solution that meets the wishes of the stakeholders.

6 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 6 From Requirements to Design n A set of requirements-oriented artifacts (and thought) inspire design-oriented artifacts.

7 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 7 Changing Hats n Until this time, we have been wearing an “investigator” hat, essentially ignoring what the solution should be. – “Do the right thing” n Now, we take off the investigator hat, and put on our “designer” hats. – “Do the thing right” n Of course, in the context of iterative development, we do this repeatedly.

8 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 8 Objectives of Interaction Diagrams n Learn how to create interaction diagrams to model use-case behavior. n Understand the similarities and differences between sequence and collaboration diagrams.

9 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 9 So Where Are We? n Discovered boundary, control, and entity classes n Assigned responsibilities to each class n Determined how to use these classes to realize use-case scenarios

10 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 10 What are Interaction Diagrams? n An interaction diagram is a graphical representation of interactions between objects – It models the dynamic aspects of a system. n There are two kinds of interaction diagrams  Sequence diagrams  Collaboration diagrams n Each provides a different view of the same interaction  Sequence diagrams are time ordered  Collaboration diagrams may include may data flow

11 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 11 What is a Sequence Diagram? n A sequence diagram shows object interactions arranged in time sequence n The diagram shows  The objects participating in the interaction  The sequence of messages exchanged n A sequence diagram contains:  Objects with their “lifelines”  Messages exchanged between objects in ordered sequence  Focus of control(optional) Sequence Diagrams

12 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 12 Review: The Anatomy of Sequence Diagrams 1: PerformResponsibility Client Object Supplier Object Message :Client:Supplier Focus of Control This is a sample script. Reflexive Message Object Lifeline 1.1: PerformAnother Responsibility Hierarchical Message Numbering

13 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 13 A sequence Diagram : Register: Sale makePayment(cashTendered) : Payment create(cashTendered) an activation box showing the focus of control

14 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 14 What Is a Collaboration Diagram? n A collaboration diagram emphasizes the organization of the objects that participate in an interaction. n The collaboration diagram shows – The objects participating in the interaction. – Links between the objects. – Messages passed between the objects. Collaboration Diagrams

15 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 15 Sample Collaboration Diagram

16 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 16 Creating Interaction Diagrams n Use cases are examined to determine the scenarios n Additional information may be needed to complete the scenario  Details of the system that have been omitted from the use case n Example : John enters the student ID number 369523449  Question : Where is the id number entered  Answer: Some sort of form is needed Registration form added

17 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 17 Sequence and Collaboration Diagram Similarities n Semantically equivalent – Can convert one diagram to the other without losing any information n Model the dynamic aspects of a system n Model a use-case scenario

18 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 18 Sequence and Collaboration Diagram Differences n Collaboration diagrams – Show relationships in addition to interactions – Better for visualizing patterns of collaboration – Better for visualizing all of the effects on a given object – Easier to use for brainstorming sessions n Sequence diagrams – Show the explicit sequence of messages – Better for visualizing overall flow – Better for real-time specifications and for complex scenarios

19 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 19 Common interaction diagram notation n Classes and instances Sale:Sales1: Sale classinstance named instance

20 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 20 Basic Sequence Diagram Notation(1/5) n Links – Sequence diagrams do not show links n Messages – Message expression between objects is on an arrowed line. n Focus of control and activation boxes

21 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 21 Basic Sequence Diagram Notation(2/5) n Creation of instances n Object lifelines

22 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 22 Basic Sequence Diagram Notation(3/5) n Conditional messages n Mutually exclusive conditional messages : B : A [ x < 10 ] calculate() message1() : C [ x > 15 ] calculate() : Bar : Foo [ color = red ] calculate() message1()

23 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 23 Basic Sequence Diagram Notation(4/5) n Iteration for a single message n Iteration of a series of messages : Simulator: Random * [i:=1..N]: num := nextInt() runSimulation()

24 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 24 Basic Sequence Diagram Notation(5/5) n Iteration over a collection (multiobject) n Messages to class objects : Foo list := synchronizedList( aList) message1() java.util.Collections not underlined, therefore a class message to class, or a static method call

25 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 25 Basic Collaboration Diagram Notation(1/7) n Links – A connection path between two objects – Indicates some form of navigation and visibility – Multiple messages and messages both ways can flow along the same single link 1: makePayment(cashTendered) 2: foo() 2.1: bar() : Register:Sale link line

26 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 26 Basic Collaboration Diagram Notation(2/7) n Messages – A sequence number is added to show the sequential order of messages – Small arrow with each message indicates the direction of the message – Messages to “self”

27 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 27 Basic Collaboration Diagram Notation(3/7) n Creation of instances 1: create(cashier) : Register:Sale {new} create message, with optional initializing parameters. This will normally be interpreted as a constructor call. > 1: make(cashier) : Register:Sale {new} if an unobvious creation message name is used, the message may be stereotyped for clarity

28 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 28 Basic Collaboration Diagram Notation(4/7) n Message number sequencing – The first message is not numbered. – Nesting is denoted by prepending the incoming message number to the outgoing message number 2: makeLineItem(ps, qty) enterItem(id, qty) 1: ps := getSpecification(id) 1.1: ps := get(id) 1.3 [not in specs & specs not full] : put( id, ps) :Register:Sale :Product Catalog :Product Specification UML notation: note the conditional message syntax : LocalProducts IProductsAdapter 1.2 [ not in specs ]: ps := getSpecification(id) specs continued in another diagram

29 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 29 Basic Collaboration Diagram Notation(5/7) n Conditional messages

30 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 30 Basic Collaboration Diagram Notation(6/7) n Iteration n Iteration over a collection (multiobject) 1 * [i:=1..N]: num := nextInt() : Simulator runSimulation() : Random iteration is indicated with a * and an optional iteration clause following the sequence number

31 Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved 31 Basic Collaboration Diagram Notation(7/7) n Messages to a class object list := synchronizedList( aList ) : InstanceOfFoojava.util.Collections msg1() not underlined, therefore a class message to class, or a static method call


Download ppt "Copyright © Hsiao-Lan Wei. 2003 All Rights Reserved Design Model Interaction diagram."

Similar presentations


Ads by Google