what are sequence diagrams? collaboration diagrams allow designer to specify message flow between...
TRANSCRIPT
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
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
Sequence Diagram
JonathonJonathon MichelleMichelleDaleDaleM1M1
M3M3M2M2
M4M4
M5M5
M6M6M7M7
M8M8M9M9
M10M10
Sequence Diagrams: An Example
• Logging into a system
:CUSTOMER :HOMEPAGE
clickLogin()clickLogin()
:HOMEPAGE
display()display()
:LOGIN PAGE
:CUSTOMER :LOGIN PAGEEnter user ID and Enter user ID and PasswordPassword
clickOK()clickOK()
:CUSTOMER :HOMEPAGE :LOGIN PAGE :ACCOUNT
validateLogin(validateLogin(userID,passworduserID,password))
loginOK()loginOK()
display()display()
«destroy»«destroy»
XX
: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»
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
The Cell phone Example
:Dialer :Cell Radio
send:Button
:Speaker
:Display
The Object Diagram for Cell Telephone System
:Button
: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
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()
Create and Destroy:Dialer :CellRadio
Connect(pno)Create()
:Connection
Destroy()
Connect(pno)
ConnectionMade()
End(pno) Disconnect(pno)
Disconnected()
X
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?
Race Condition:SendbuttonAdapter
:Dialer :Cellradio :Ringer
Answer()
:SendbuttonAdapter
:Dialer :Cellradio :Ringer
Send()Connect(pno)
Send()
Incoming call()
Incoming call()
ring()
ring()
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