what are sequence diagrams? collaboration diagrams allow designer to specify message flow between...

17
What are Sequence Diagrams? • Collaboration Diagrams allow designer to specify message flow between collaborating objects – Focus on relationship between objects • Sequence Diagrams contain the same information as Collaboration Diagrams – Focus on sequence , not relationship

Upload: miranda-clark

Post on 04-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

What are Sequence Diagrams?

• Collaboration Diagrams allow designer to specify message flow between collaborating objects– Focus on relationship between objects

• Sequence Diagrams contain the same information as Collaboration Diagrams– Focus on sequence, not relationship

Page 2: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

What if there are many object interactions?

JonathonJonathon

MichelleMichelle

DaleDale1:M14:M410:M10

Collaboration Diagram is too cluttered and confusing

9:M97:M7

6:M62:M2

3:M35:M5

8:M8

Page 3: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Sequence Diagram

JonathonJonathon MichelleMichelleDaleDaleM1M1

M3M3M2M2

M4M4

M5M5

M6M6M7M7

M8M8M9M9

M10M10

Page 4: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Sequence Diagrams: An Example

• Logging into a system

:CUSTOMER :HOMEPAGE

clickLogin()clickLogin()

Page 5: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

:HOMEPAGE

display()display()

:LOGIN PAGE

Page 6: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

:CUSTOMER :LOGIN PAGEEnter user ID and Enter user ID and PasswordPassword

clickOK()clickOK()

Page 7: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

:CUSTOMER :HOMEPAGE :LOGIN PAGE :ACCOUNT

validateLogin(validateLogin(userID,passworduserID,password))

loginOK()loginOK()

display()display()

«destroy»«destroy»

XX

Page 8: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

:CUSTOMER :HOMEPAGE :LOGIN PAGE :ACCOUNT

validateLogin(validateLogin(userID,passworduserID,password))

loginOK()loginOK()

display()display()

«destroy»«destroy»

XX

clickLogin()clickLogin()

display()display()

Enter user ID and PasswordEnter user ID and Password

clickOK()clickOK()

«create»«create»

Page 9: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

How about an ATM machine?

• Basic Course (UC12: withdraw money)– Insert Card– Enter PIN – Select “Withdrawal” from Main Menu– Enter Amount– Take cash– Take card

Page 10: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between
Page 11: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

The Cell phone Example

:Dialer :Cell Radio

send:Button

:Speaker

:Display

The Object Diagram for Cell Telephone System

:Button

Page 12: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

:Dialer :Cell Radio

send:Button

:Speaker

:Display

The Collaboration Diagram for Cell Telephone System

:Button

1*: Digit

1.1: Display Digit

1.2: Emit Tone

2: Send

2.1: Connect

2.1.1: In Use

Page 13: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Cell Phone Sequence Diagram

digit:Button :DigitbuttonAdapter

:Dialer :Display :Speaker

Buttonpressed()Digit(code)

DisplayDigit(code)

EmitTone(code)

send:Button :SendbuttonAdapter

:Dialer :Cellradio :Display

Buttonpressed()

Send()Connect(pno)

InUse()

Page 14: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Create and Destroy:Dialer :CellRadio

Connect(pno)Create()

:Connection

Destroy()

Connect(pno)

ConnectionMade()

End(pno) Disconnect(pno)

Disconnected()

X

Page 15: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Race Conditions

• Occurs when single object concurrently receives message from competing clients

• Consider an incoming call on a cell phone– Cell radio detects incoming call and sounds ringer– Cell radio also informs Dialer that a call is coming in and

places the dialer in a special state– In this state, the Send button, when pressed, answers the

call– The send button has different meanings in different

circumstances (what is this called?)

• But what happens if the incoming call comes when a outgoing call is being made?

Page 16: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Race Condition:SendbuttonAdapter

:Dialer :Cellradio :Ringer

Answer()

:SendbuttonAdapter

:Dialer :Cellradio :Ringer

Send()Connect(pno)

Send()

Incoming call()

Incoming call()

ring()

ring()

Page 17: What are Sequence Diagrams? Collaboration Diagrams allow designer to specify message flow between collaborating objects –Focus on relationship between

Try One

• A sales clerk starts a new transaction• He/she enters the transaction details

(account# and product)• System retrieves product and customer

details, and associated discount• Clerk confirms transaction• The system updates receivables accounts• System informs clerk that transaction is

complete