19
1 CHAPTER 12 Object Interaction Software System Engineering (260CT)

Software System Engineering - Chapter 12

Embed Size (px)

DESCRIPTION

Software System Engineering

Citation preview

Page 1: Software System Engineering - Chapter 12

1

CHAPTER 12Object Interaction

Software System Engineering

(260CT)

Page 2: Software System Engineering - Chapter 12

2

In This Lecture You Will Learn:

How to develop object collaboration from use cases

How to model object collaboration using an interaction sequence diagram

How to cross-check between interaction diagrams and a class diagram

Page 3: Software System Engineering - Chapter 12

3

Object Messaging

:Campaign anAdvert:Advert

getCost( )

Objects communicate by sending messages

Sending the message getCost() to an Advert object, might use the following syntax advertCost = anAdvert.getCost()

Page 4: Software System Engineering - Chapter 12

4

Focus of Control

Indicates times during an activation when processing is taking place within that object

Parts of an activation that are not within the focus of control represent periods when, for example, an operation is waiting for a return from another object

May be shown by shading those parts of the activation rectangle that correspond to active processing by an operation

Page 5: Software System Engineering - Chapter 12

5

Focus of Control

:Client :Campaign :Advert getName()

listCampaigns()

checkCampaignBudget()

*getCampaignDetails()

* getCost()

getOverheads()

Campaign Manager

Page 6: Software System Engineering - Chapter 12

6

Further Notation:ClassA :ClassB

a

b{b.sendtime – a.sendtime < 3 sec}

c < 5 sec.

d{d.receivetime – d.sendtime < 1.5 sec}

e

{e.sendtime -d.receivetime < 6 sec}

Synchronous (blocking) message

Asynchronous message

Callback

Timeconstraints

Construction marks to show

time constrained

interval

{e’ – e < 6 sec}

An active object

Here e is used as shorthand for e.sendtime and e’ represents e.receivetime

Page 7: Software System Engineering - Chapter 12

7

Message Branching

[totalCost budget] Advert()

addCostedAdvert()

[totalCost > budget] Request()

newAd:Advert

newRequest:Request

:Campaign

budget:=checkCampaignBudget()checkCampaignBudget() results in further interaction

Campaign Manager

Page 8: Software System Engineering - Chapter 12

8

Handling Complexity

Complex diagrams can be split into two or more smaller diagrams suitably annotated

Alternatively a group of objects can be represented by a single lifeline, and interaction among these objects is shown on a different diagram

Page 9: Software System Engineering - Chapter 12

9

Handling Complexity

:AddAdvertUI

:AddAdvert

showClientCampaigns()selectClient()

selectCampaign() showCampaignAdverts()

createNewAdvert()addNewAdvert()

listCampaigns()

addNewAdvert()

listAdverts()

These flows are continued next figure

startInterface()*getClient()

Campaign Manager

Page 10: Software System Engineering - Chapter 12

10

Handling Complexity

listCampaigns()

addNewAdvert()

listAdverts()

*getCampaignDetails()

Advert()

*getAdvertDetails()

:Client :Campaign

:Advert

newAd:Advert

These flows are continued

from the previous figure

*getClient()

Page 11: Software System Engineering - Chapter 12

11

Object Grouping

Lifeline representing a set of objectsgetName()

CampaignAdverts

checkCampaignBudget()

:Client

listCampaigns()

Campaign Manager

Page 12: Software System Engineering - Chapter 12

12

Collaboration Diagrams

Hold the same information as sequence diagrams

Show links between objects that participate in the collaboration

No time dimension, sequence is captured with sequence numbers

Sequence numbers are written in a nested style (for example, 3.1 and 3.1.1) to indicate the nesting of control within the interaction that is being modelled

Page 13: Software System Engineering - Chapter 12

13

Collaboration Diagrams

3.1.1: listCampaigns()

3.1.1.1: *getCampaignDetails()

5.1.1.1: Advert()

4.1.1.1: *getAdvertDetails()

5.1.1: addNewAdvert()

:AddAdvertUI :AddAdvert

:Client :Campaign

:Advert

3.1: showClientCampaigns()3: selectClient()

4: selectCampaign() 4.1: showCampaignAdverts()

4.1.1: listAdverts()

5: createNewAdvert() 5.1: addNewAdvert()

newAd:Advert

2: startInterface()

1:*getClient()

Campaign Manager

One allocation of responsibilities for use case Add a new advert to a campaign

Page 14: Software System Engineering - Chapter 12

14

Collaboration Diagrams

3.1.2: *getCampaignDetails()

5.1.1.1: Advert()

4.1.2: *getAdvertDetails()

5.1.1: addNewAdvert()

:AddAdvertUI :AddAdvert

:Client :Campaign

:Advert

3.1: showClientCampaigns()3: selectClient()

4: selectCampaign() 4.1: showCampaignAdverts()

4.1.1: listAdverts()

5: createNewAdvert() 5.1: addNewAdvert()

newAd:Advert

2: startInterface()

3.1.1: listCampaigns()

1:*getClient()

Campaign Manager

Alternative allocation of responsibilities for use case Add a new advert to a campaign

Page 15: Software System Engineering - Chapter 12

15

Message Labels Type of message Syntax example

Simple message. 4: addNewAdvert()

Nested call with return value.The return value is placed in the variable name.

 

3.1.2: name:= getName()

Conditional message.This message is only sent if the condition [balance > 0] is true.

 [balance > 0] 5: debit(amount)

Synchronization with other threads.Message 4: playVideo() is invoked only once the two concurrent messages 3.1a and 3.1b are completed.

 3.1a, 3. 1b / 4:playVideo() 

Page 16: Software System Engineering - Chapter 12

16

Navigating Links

Page 17: Software System Engineering - Chapter 12

17

Model Consistency The allocation of operations to objects must be

consistent with the class diagram and the message signature must match that of the operation• Can be enforced through CASE tools

Every sending object must have the object reference for the destination object• Either an association exists between the classes or another

object passes the reference to the sender

• This issue is key in determining association design (See Chapter 14)

• Message pathways should be carefully analysed

Page 18: Software System Engineering - Chapter 12

18

Model Consistency

If both sequence and collaboration diagrams are prepared they should be consistent

Messages on interaction diagrams must be consistent with the statecharts for the participating objects

Implicit state changes in interaction diagrams must be consistent with those explicitly modelled in statecharts

Page 19: Software System Engineering - Chapter 12

19

Summary

In this lecture you have learned about: How to develop object collaboration from use

cases How to model object collaboration using an

interaction sequence diagram How to model object collaboration using an

interaction collaboration diagram How to cross-check between interaction

diagrams and a class diagram