lecture09-sequencediagrams

Embed Size (px)

Citation preview

  • 7/25/2019 lecture09-sequencediagrams

    1/18

    1

    UML Sequence Diagrams

    .

  • 7/25/2019 lecture09-sequencediagrams

    2/18

    2

    UML sequence diagrams

    sequence diagram: an "interaction diagram" thatmodels a single scenario executing in the system perhaps 2nd most used UML diagram (behind class diagram)

    relation o UML diagrams to other exercises: !! cards #$ class diagram

    use cases #$ sequence diagrams

  • 7/25/2019 lecture09-sequencediagrams

    3/18

    3

    %ey parts o a sequence diag&

    participant: an ob'ect or entity that acts in thesequence diagram sequence diagram starts ith an unattached "ound message"

    arro

    message: communication beteen participant ob'ects

    the axes in a sequence diagram: horiontal: hich ob'ect*participant is acting

    +ertical: time (don #$ orard in time)

  • 7/25/2019 lecture09-sequencediagrams

    4/18

    4

    Sequence dg& rom use case

  • 7/25/2019 lecture09-sequencediagrams

    5/18

    5

    epresenting ob'ects

    Squares ith ob'ect type, optionally preceded by ob'ectname and colon rite ob'ect-s name i it clariies the diagram ob'ect-s "lie line" represented by dashed +ert& line

  • 7/25/2019 lecture09-sequencediagrams

    6/18

    6

    message (method call) indicated by horiontalarro to other ob'ect rite message name and arguments abo+e arro

    Messages beteen ob'ects

  • 7/25/2019 lecture09-sequencediagrams

    7/187

    Messages, continued

    message (method call) indicated by horiontalarro to other ob'ect dashed arro bac. indicates return dierent arroheads or normal * concurrent

    (asynchronous) methods

  • 7/25/2019 lecture09-sequencediagrams

    8/188

    Lietime o ob'ects

    creation: arro ith -ne-ritten abo+e it notice that an ob'ect created

    ater the start o the scenarioappears loer than the

    others

    deletion: an / at bottom oob'ect-s lieline

    0a+a doesn-t explicitly deleteob'ects1 they all out oscope and are garbage#collected

  • 7/25/2019 lecture09-sequencediagrams

    9/189

    ndicating method calls

    activation: thic. box o+er ob'ect-s lie line1 dranhen ob'ect-s method is on the stac. either that ob'ect is running its code, or it is on the stac.

    aiting or another ob'ect-s method to inish

    nest to indicate recursion

    Activation

    Nesting

  • 7/25/2019 lecture09-sequencediagrams

    10/1810

    ndicating selection and loops

    rame: box around part o a sequence diagram to indicateselection or loop if #$ (opt) 3condition4 if/else #$ (alt) 3condition4, separated by horiontal dashed line loop #$ (loop) 3condition or items to loop o+er4

  • 7/25/2019 lecture09-sequencediagrams

    11/1811

    lin.ing sequence diagrams

    i one sequence diagram is too large or reers to another diagram,indicate it ith either: an uninished arro and comment a "re" rame that names the other diagram hen ould this occur in our system5

  • 7/25/2019 lecture09-sequencediagrams

    12/1812

    6xample sequence diagram

  • 7/25/2019 lecture09-sequencediagrams

    13/1813

    7orms o system control

    8hat can you say about the control lo o each o theolloing systems5 s it centralied5 s it distributed5

  • 7/25/2019 lecture09-sequencediagrams

    14/1814

    7laed sequence diagram 9

    8hat-s rong ith this sequence diagram5 (Loo. at the UMLsyntax and the +iability o the scenario&)

  • 7/25/2019 lecture09-sequencediagrams

    15/1815

    7laed sequence diagram 2

    8hat-s rong ith this sequence diagram5

  • 7/25/2019 lecture09-sequencediagrams

    16/1816

    8hy not 'ust code it5

    Sequence diagrams can be somehat close to the codele+el& So hy not 'ust code up that algorithm ratherthan draing it as a sequence diagram5

    a good sequence diagram is still a bit abo+e the le+elo the real code (not all code is dran on diagram)

    sequence diagrams are language#agnostic (can be

    implemented in many dierent languages non#coders can do sequence diagrams easier to do sequence diagrams as a team can see many ob'ects*classes at a time on same

    page (+isual bandidth)

  • 7/25/2019 lecture09-sequencediagrams

    17/1817

    Sequence diagram exercise 9

    Let-s do a sequence diagram or the olloing casualuse case, Start New Poker Round :

    he scenario begins hen the player chooses to start a neround in the U& he U as.s hether any ne players ant to

    'oin the round1 i so, the ne players are added using the U&

    ;ll players- hands are emptied into the dec., hich is thenshuled& he player let o the dealer supplies an ante bet othe proper amount&

  • 7/25/2019 lecture09-sequencediagrams

    18/1818

    Sequence diagram exercise 2

    Let-s do a sequence diagram or the olloing casualuse case,Add Calendar Appointment : he scenario begins hen the user chooses to add a neappointment in the U& he U notices hich part o the calendar isacti+e and pops up an ;dd ;ppointment indo or that date and time& he user enters the necessary inormation about the appointment-sname, location, start and end times& he U ill pre+ent the user romentering an appointment that has in+alid inormation, such as an emptyname or negati+e duration& he calendar records the ne appointmentin the user-s list o appointments& ;ny reminder selected by the user isadded to the list o reminders&

    the user already has an appointment at that time, the user isshon a arning message and as.ed to choose an a+ailable time orreplace the pre+ious appointment& the user enters an appointmentith the same name and duration as an existing group meeting, thecalendar as.s the user hether he*she intended to 'oin that groupmeeting instead& so, the user is added to that group meeting-s list o

    participants&