POOD 04

Document Sample
POOD 04 Powered By Docstoc
					Chapter 4
Advanced Interaction Modelling with
Sequence Diagrams
Module Outline
• Elements on a Sequence Diagram
   – Part of Interaction Diagrams
• A Basic Sequence Diagram in Design
   – Design-level sequence diagrams
• Focus of Control & return messages
• Mapping Class Diagrams to Sequence
  Diagrams
• Examples from Hospital Management
  System
Figure 4.1:  Elements of a Sequence
Diagram in Design

                                    1: enquiresAvailability
                                                              Message
                     The Actor
     : Patient
                                                              Self Message

                                                              return message
 aPatient :Patient
                                                              Asynchornous
                      Object
                                                               Message


                                                              Destroying an
                                                              Object
                     Time Line

                                      Patient Checks
                                    Availability of Doctor    Steps in the
                                                              Sequence
                 Focus of Control
                                                              Notes
Figure 4.2:
Basics of a Sequence Diagram


                                                         Collaborating
                                                           Objects


         aPatient:Patient                       aDoctor:Doctor


  Time           +getSchedule(DoctorID, Schedule):Void
  Line



                                              Message
Figure 4.3:
A Design-Level Sequence Diagram
                                                                                                      These objects
                                                                                                      are created
                                                                                                      here...
                     aPatient :                     : Doctor
   : PatientForm                                                     : PatientTable   : DoctorTable
                      Patient
        bookConsultation( )



                                  getSchedule( )
                                                                 getDoctorRoster( )

                                                        getPatientRecord( )



                                  getAvailable( )


                                    availability
Figure 4.4:
Advancing the Sequence Diagrams from
Analysis to Design: Showing specific objects


                                                                        aDoctor
                                     System   : ActorPatient
    : ActorPatient


               checkAvailability()
                                                      checkAvailability( )




                                                           (B)
                     (A)
                                                 Design Sequence Diagram
          Analysis Sequence Diagram
                                                   Shows ‘Doctor’ – a
                Read ‘System’
                                                      Specific object
Figure 4.5:    Understanding Focus of
Control and return message


                aPatient :                     : Doctor
                 Patient




                             getSchedule( )




     Focus of
     Control                 getAvailable( )


                               availability


                                                           Return
                                                          Protocol
Figure 4.6:
Creating and Destroying an Object


                   : PatientForm

                                      aPatient :
                                       Patient
  ‘Creating an
    Object’             bookConsultation( )
Shown with the
arrow pointing
 directly to the                                   ‘Deleting an Object’
     Object                                        Shown with a Cross
                                                     on the Timeline
Figure 4.7:   Relating Sequence
Diagrams to Class Diagrams
    Objects on Sequence
Diagrams belong to Classes in
       Class Diagram




                          aPatient:
                         Patient
                                                                            Patient

                                                              -P_ID NUM;
      +checkPatientDetails(P_ID=101 , P_Details): Void
                                                             +checkPatientDetails(P_ID,P_Details);




                                               Messages on Sequence Diagrams
                                               come from Methods available to
                                                 the Class on Class Diagrams
Advantages & Limitations of a
Sequence Diagram in Design
Advantages                              Limitations
•   Show a sequence of messages         •   Since they are “snap shots” of
    passed between collaborating            what happens in a give time
    objects within a given time             period, they do not show a
    period                                  complete sequence; they are
•   Provides an ideal “snap shot” of        incomplete;
    what happens in a time period       •   The number of sequence
    in the system                           diagrams required in a given
•   Enables identification of missing       design is not clearly known. It
    objects                                 depends on the experience of
•   Enables identification of missing       the designer when to stop.
    operations within a class               Theoretically numerous
                                            sequence diagrams can be
•   Mapping between sequence                drawn within a given design.
    diagrams and class diagrams
    enhance quality of class            •   The way in which system
    diagrams                                designers use these diagrams
                                            (technical level) is different to
•   Messages with their signatures          the way the business analysts
    are a source of information to          use them (business process
    designers and programmers               level); Inappropriate type of
                                            usage of these diagrams can be
                                            counterproductive in practice.
Figure 4.8:  ‘Registering a Patient’
Sequence Diagram in Design

           : Patient Registration
                                    : TransactionManager        : Patient   : DatabaseManager : PatientTable
                  Interface

                              display()

     Details of
     Patient are       save( )
     entered               savePatient( )        updatePatient( )
     here and
     saved.
                                                          savePatientDtls( )

                                                                    getPatientDtls( )

                                                                                   savePatientRecord( )




                                          Only the <<control>> objects
                                          continue to exist. Rest are deleted
                                          after the sequence of creating a
                                          patient is completed.
Figure 4.9:
‘Updating a Calendar’ Sequence
Diagram in Design


                 : Calendar
                                  : DatabaseManager




                                                          : CalendarTable
                                                   create( )

                        CheckSchedule( )

                                                                            Calendar record is
  getScheduleDtls(DoctorID : Integer, ScheduleDetails : Schedule)           created and updated with
                                                                            the Schedule of the
                                               saveSchedule( )              Doctor from the
                                                                            <<entity>> Calendar
                                                                            Object belonging to that
                                                                            Doctor.
Figure 4.10:
‘Changing Booking for a Consultation’
sequence diagram in design

                                                                                 Two Objects
                                                                                 belonging to a
 : ConsultationBookingForm                                                       Class; One deleted
                                 aConsultation :         10am Booking :          and another added
                                  Consultation              Booking              to aConsultation
                changeConsultation( )
                                             deleteBooking( )


                                                                          4pm Booking :
                                                                            Booking
                                                      createBooking( )



                               updateConsultationBooking( )
Figure 4.11:
‘Paying a Bill’ Sequence Diagram

  : PaymentForm : PaymentManager         : Patient    : TransactionManager : PaymentTable : A96-VisaInterface

      createPaymentForm( )


                          getPatientDtls( )

      displayPaymentForm( )
                                    savePayment( )

                                         verifyPaymentDtls(VisaCardNumber : Integer, ExpiryDate : Date, Amount : Currency)

                                                                 savePaymentDtls( )




                     Note that this sequence assumes
                     successful payment. An unsuccessful
                     verification of card will need a separate
                     sequence diagram or an Interaction
                     Overview Diagram (not shown here)
Conclusions
• Discussed in detail the Sequence diagrams
  (as part of Interaction diagrams)
   – Collaboration diagrams have been
     renamed to Communication diagrams in
     UML 2.0 and not discussed here as they
     do the same work as Sequence
     diagrams.
   – Demonstrated mapping between
     sequence and class diagrams
Workbook exercises
• For the classroom
Workbook Exercises
1. Map a Sequence diagram to
   corresponding Class diagram
2. Draw a sequence diagram showing TWO
   or more objects belonging to the same
   Class
  – This will relate to multiplicity on the
     class diagram
3. Draw a sequence diagram showing the
   same message appearing more than once
   on the same sequence diagram

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:8/31/2012
language:English
pages:17