Interaction Diagrams

Document Sample
Interaction Diagrams Powered By Docstoc
					  Interaction Diagrams
                                       Engineering 5895: Software
                                        Engineering 5895: Software
                                       Design
                                        Design




          Modeling Behaviour




10/5/01         Interaction Diagrams                          1
Interaction Diagrams
                                            Engineering 5895: Software
                                            Design


•   Typically use: capture Use Case behaviour
•   Shows how groups of objects collaborate
•   Only used in critical places
•   Two forms
     • Collaboration Diagrams
     • Sequence Diagrams



10/5/01              Interaction Diagrams                           2
Collaboration Diagram
                                              Engineering 5895: Software
                                              Design




            user
                               backUp




          Teaching Machine: backup use case


10/5/01               Interaction Diagrams                            3
Collaboration Diagram
                                                                               Engineering 5895: Software
                                                                               Design

           CommandInterface

                      1



                          1
                  DisplayManager
                                                                     Display
                                   1                          1..*




                                                      Expression
                                                        Engine



          TM: Partial Class Diagram

10/5/01                                Interaction Diagrams                                            4
Collaboration Diagram
                                                                                                 Engineering 5895: Software
                                                                                                 Design


                 :CommandInterface
                                                                   This is a simplification of
                                                                   the actual process used
                                5: refresh                         in the TeachingMachine
     Object
                    4: backUp
                                                                   2: backMyself
                         :DisplayManager
                                                                                                 Self Delegation



          Link                                   3: sysBackUp    :ExpressionEngine
                                   6: *update

                     :Display


                                                Message                         1: backUp        :User

                                                            Sequence No

                        TM: Backup Collaboration Diagram


10/5/01                                            Interaction Diagrams                                                  5
Detailed Message Syntax
                                        Engineering 5895: Software
                                        Design


• Object names are in form of Object:Class
• Either or both parts may be used
• If class only, include the colon



  myA:A                                                someB:B




10/5/01          Interaction Diagrams                           6
Detailed Message Syntax
                                             Engineering 5895: Software
                                             Design


• Messages are labelled arrow on a link line
• Sequence numbers show the order
• Any number of messages may flow along
  a link
             1: message1( )

             2: message2( )

             5: message5( )


  myA:A                                                     someB:B



10/5/01               Interaction Diagrams                           7
 Detailed Message Syntax
                                                                       Engineering 5895: Software
                                                                       Design


  • Parameters may be added
  • So may return values


                                 1: deposit( amount: Money)
Return variable name possible


                                5: allowed := overdraft( ) : boolean


    myA:A                                                                             someB:B



 10/5/01                                      Interaction Diagrams                             8
    Detailed Message Syntax
                                                                            Engineering 5895: Software
                                                                            Design

     • Iteration may be indicated
            • simple * meaning for All
            • explicitly

                                      1*: close( )
Iteration explicitly specified


                                 4*:[i:=1..10] size:=getSize(): Rectangle


       myA:A                                                                               Window



    10/5/01                                          Interaction Diagrams                           9
Detailed Message Syntax
                                            Engineering 5895: Software
                                            Design

• Create() is a special message for
  construction
• <<new>> stereotype may be used on
  newly instantiated object

            2: create( window:int)

                                                         <<new>>
myA:A                                                 window:Window



10/5/01              Interaction Diagrams                          10
   Message Sequencing
                                                                  Engineering 5895: Software
                                                                  Design


                                   1:msg2()
                        myA:A                            window:Window
   msg1()

                                                                       1.1:msg3()
                                                     2.1:msg5()

Initiating message no           2:msg4()
number at all                                                aC:C



                                                                    2.2:msg6()




                                                              theD:D

   10/5/01                        Interaction Diagrams                                   11
Conditional Messages
                                            Engineering 5895: Software
                                            Design


• Condition clause in square brackets
• Message only if condition true

                        1:[isLegal]move()
          :Referee                              human:Player
 eval()

                                                                1.1: mvTo()




                                                  piece:Checker


10/5/01              Interaction Diagrams                          12
Mutually Exclusive Conditions
                                                              Engineering 5895: Software
                                                              Design


• Letters designate mutual exclusion
• if (test) msg2() ( msg(3) )
      else msg4() ( msg5() )
                            1a:[test]msg2()
          myA:A                                          someB:B
initM()

                                         Note: letters             1a.1:msg3()
                  1b:[!test]msg4()       carried over


                                1b.1:msg5()
          theD:D                                          aC:C

10/5/01                       Interaction Diagrams                                   13
Collaboration Diagrams
                                             Engineering 5895: Software
                                             Design


• Emphasis on static connections
• Show sequences by numbering messages
• Alternative is Sequence Diagram
     • Different view of the same data




10/5/01               Interaction Diagrams                          14
Sequence Diagrams
                                            Engineering 5895: Software
                                            Design


• Emphasis on sequence
• Particularly good with use cases during
  inception/elaboration phases
     • classes may not be worked out yet
• Many designers prefer them in all phases




10/5/01              Interaction Diagrams                          15
          Customer                             :ATM                        :System




                                                                             Engineering 5895: Software
                        insertCard()                                         Design

              pinPrompt()                                                                lifeline

                          enterPin()                    verify()

                                                       authorize()                        activation
             transactionPrompt()

                     checkingWithdraw()

             amountPrompt()

                            amount()                  request()


                offerMore()                            approved()

                              refuse()

                                                                deletion

10/5/01                                  Interaction Diagrams                                          16
Message Syntax
                                                                       Engineering 5895: Software
                                                                       Design


• Same as for collaboration diagrams
• Without sequence numbers

     :A                     :B                   :C


                  setup()        *setup()                           condition


                                 iteration                 [noDs]
                                                           new()                :D
            allDone()

               cleanUp()
                                       return (optional)
                                                                    object creation
10/5/01   destruction message       Interaction Diagrams                                      17
Concurrent Processes
                                 Engineering 5895: Software
                                 Design




10/5/01   Interaction Diagrams                          18
Concurrent Processes
                                 Engineering 5895: Software
                                 Design




10/5/01   Interaction Diagrams                          19

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:12/17/2012
language:Unknown
pages:19