software system engineering - chapter 12

Post on 27-Jun-2015

74 Views

Category:

Engineering

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Software System Engineering

TRANSCRIPT

1

CHAPTER 12Object Interaction

Software System Engineering

(260CT)

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

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()

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

5

Focus of Control

:Client :Campaign :Advert getName()

listCampaigns()

checkCampaignBudget()

*getCampaignDetails()

* getCost()

getOverheads()

Campaign Manager

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

7

Message Branching

[totalCost budget] Advert()

addCostedAdvert()

[totalCost > budget] Request()

newAd:Advert

newRequest:Request

:Campaign

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

Campaign Manager

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

9

Handling Complexity

:AddAdvertUI

:AddAdvert

showClientCampaigns()selectClient()

selectCampaign() showCampaignAdverts()

createNewAdvert()addNewAdvert()

listCampaigns()

addNewAdvert()

listAdverts()

These flows are continued next figure

startInterface()*getClient()

Campaign Manager

10

Handling Complexity

listCampaigns()

addNewAdvert()

listAdverts()

*getCampaignDetails()

Advert()

*getAdvertDetails()

:Client :Campaign

:Advert

newAd:Advert

These flows are continued

from the previous figure

*getClient()

11

Object Grouping

Lifeline representing a set of objectsgetName()

CampaignAdverts

checkCampaignBudget()

:Client

listCampaigns()

Campaign Manager

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

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

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

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() 

16

Navigating Links

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

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

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

top related