Activity Diagrams & State Machines

Activity Diagrams & State Machines

2IW80 Software specification and architecture Activity diagrams & State machines Alexander Serebrenik This week sources Slides by Site by David Meredith, Kirill Fakhroutdinov Aalborg University, DK GE Healthcare, USA Before we start… True or False? 1. A web server can be an actor in a use case diagram. 2. Guarantee is an action that initiates the use case. 3. Use case “Assign seat” includes the use case “Assign window seat”. 4. Generalization is represented by an arrow with a hollow triangle head. 5. Every use case might involve only one actor. / SET / W&I 24-2-2014 PAGE 2 Before we start… T, unless it is a part of the system True or False? you want to model 1. A web server can be an actor in a use case diagram. Guarantee is a postcondition. An action that initiates the use case is called “trigger”. 2. Guarantee is an action that initiates the use case. 3. Use case “Assign seat” includes the use case “Assign window seat”. 4. Generalization is represented by an arrow with a hollow triangle head. 5. Every use case might involve only one actor. / SET / W&I 24-2-2014 PAGE 3 Before we start… True or False? 1. A web server can be an actor in a use case diagram. 2. GuaranteeNo, the correct is an relationaction that here initiates is extension the use (<<extend>>); case. <<include>> suggests that “Assign window seat” is always called whenever “Assign seat” is executed. 3. Use case “Assign seat” includes the use case “Assign window seat”. 4. Generalization is represented by an arrow with a hollow triangle head. Yes 5. Every use case might involve only one actor. No, why? / SET / W&I 24-2-2014 PAGE 4 Phone call use case / SET / W&I Phone call use case Disadvantages 1. To understand alternatives, one has to read them simultaneously with the main scenario. 2. Missing alternatives are difficult to spot. 3. Main scenario enforces sequential execution, missing potential for concurrent execution. / SET / W&I Activity diagram: Let us start initial node or start marker accept signal The user picks up the telephone hook connected to the telephone line “A”. decision [the line [else] is free] send signal Connect the user Provide the user to the ongoing with a dial tone. conversation final node or stop marker … / SET / W&I 24-2-2014 PAGE 7 The next step • Main scenario: The user dials number “B”. • Alternative step: If the user does not dial a number for a certain amount of time, a permanent tone is emitted by the switch center, no further call will be accepted and the user has to replace the hook. • Two processes: − wait for the user to dial a number (“main scenario”) − wait for certain amount of time, say 5 sec; • When 5 seconds passed, abort the “main scenario” waiting / SET / W&I 24-2-2014 PAGE 8 Modeling timeout interruptible activity region The user dials Wait for 5 sec number “B” interrupting edge Emit a permanent tone / SET / W&I 24-2-2014 PAGE 9 Continuing… interruptible activity region The user dials Wait for 5 sec number “B” interrupting edge (internal) action Forward the call request Emit a to the switch center. permanent tone [line B [else] is busy] [B has call [else] Step e waiting] Send a busy tone Step e-2 / SET / W&I 24-2-2014 PAGE 10 Step e • If line “B” is not busy, the call request is forwarded to “B” and a tone is sent to “A”. • No indication whether the call request should first be forwarded, and the tone sent next, or vice versa. • We should not disallow any of these options. • Execute both in parallel fork • Wait till both call request forwarding and tone setting are successful. Forward the call Set tone request to “B” to “A” join / SET / W&I 24-2-2014 PAGE 11 Step e-2 • The user at “A” will receive a “call waiting” tone from the switch center. When the line “B” becomes free, sub- scenario (e-g) follows. merge • Merge is needed to allow Send “call multiple data flows in the waiting” to A same point. [B busy] [else] decision Sub-scenario (e-g) • What would happen if B stays busy all the time? • Omission in the use case. / SET / W&I 24-2-2014 PAGE 12 Step e-2 • The user at “A” will receive a “call waiting” tone from the switch center. When the line “B” becomes free, sub- scenario (e-g) follows. merge Wait 1 min Send “call waiting” to A [B busy] [else] decision Sub-scenario (e-g) Send a busy tone / SET / W&I 24-2-2014 PAGE 13 The user picks up the telephone hook connected to the telephone line “A”. [line free] [else] Steps a - f Provide the user Connect the user to the with a dial tone. ongoing conversation Wait The user dials 5 sec number “B” Emit a Forward the call request permanent tone to the switch center. [B call [B busy] [else] waiting] [else] Wait Send a busy tone 1 min Send “call waiting” to A Forward the call Set tone request to “B” to “A” [B busy] [else] Send a busy tone “B”’s telephone rings. Summary of activity diagram elements (so far) Graphical Description “Keywords” representation Action Send invoice Control start / stop markers flow decision if merge loops, end-if fork / join and, parallel Signals incoming (accept), user outgoing (send) time-based when, time Interrupts interruptible activity cancel, region, interrupting edge interrupt an alternative notation for an interrupting edge / SET / W&I 24-2-2014 PAGE 15 The user picks up the telephone hook connected to the telephone line “A”. Issues? [line free] [else] Disadvantages? Provide the user Connect the user to the with a dial tone. ongoing conversation Wait The user dials 5 sec number “B” Emit a Forward the call request permanent tone to the switch center. [B call [B busy] [else] waiting] [else] Wait Send a busy tone 1 min Send “call waiting” to A Forward the call Set tone request to “B” to “A” [B busy] [else] Send a busy tone “B”’s telephone rings. The user picks up the telephone hook connected to the telephone line “A”. Issues? [line free] [else] Disadvantages? Provide the user Connect the user to the with a dial tone. ongoing conversation Wait The user dials 5 sec number “B” Emit a Forward the call request Too complex! permanent tone to the switch center. [B call [B busy] [else] waiting] [else] Wait Send a busy tone 1 min Send “call waiting” to A Forward the call Set tone request to “B” to “A” [B busy] [else] Send a busy tone “B”’s telephone rings. The diagram became quite complex • Reorganize links to reduce the number of self-crossings, links between different cases of the activity • Fosters reuse similarly to labels • Reorganize the activity using subactivities • Fosters reuse similarly to subroutines / SET / W&I 24-2-2014 PAGE 18 Reorganize links • Use connectors instead of uninterrupted lines Send a busy tone “B”’s telephone rings. Reorganize links • Use connectors instead of uninterrupted lines [else] Wait Send a busy tone 1 min Send “call waiting” to A Forward the call Set tone request to “B” to “A” [B busy] [else] Send a busy tone “B”’s telephone rings. Reorganize links • Use connectors instead of uninterrupted lines [else] A Wait Send a busy tone 1 min Send “call waiting” to A Forward the call Set tone [else] request to “B” to “A” [B busy] A Send a busy tone “B”’s telephone rings. • Beware: Too many connectors hinder comprehension! Reorganize the activity using subactivities • Use subactivities to reuse or simplify the structure name of the subactivity Forward the call request Start successful to the switch center. communication [B busy] [else] … rake Forward the call Set tone request to “B” to “A” Start successful communication “B”’s telephone rings. … Callee Caller / SET / W&I 24-2-2014 PAGE 22 Example of a subactivity: processing an order input parameter and its type activity containing actions, etc input parameter all invocations use the same execution, like object passed from static in Java one action to another / SET / W&I 24-2-2014 PAGE 23 Parameters • Activities can have parameters, • what about individual actions? / SET / W&I 24-2-2014 PAGE 24 Parameters • Activities can have parameters, • what about individual actions? • Pins represent action parameters message recipient • Optional: use only for data produced Send a notification and used / SET / W&I 24-2-2014 PAGE 25 Parameters • Activities can have parameters, • what about individual actions? • Pins represent action parameters message recipient • Optional: use only for data produced Send a notification and used • Data can be also produced by Cancel appointmnt transforming “output pin” data to appointment “input pin” data message recipient Send a notification / SET / W&I 24-2-2014 PAGE 26 Pins can also be used for expansion regions • We’ve seen an example of a loop • But what if a loop is used to Send “call waiting” to A traverse a collection? [B busy] [else] void reviewSubmissions(Collection<Submission> c) { for (Submission s : c) s.review(); … } / SET / W&I 24-2-2014 PAGE 27 Pins can also be used for expansion regions • We’ve seen an example of a loop • But what if a loop is used to Send “call waiting” to A traverse a collection? [B busy] [else] void reviewSubmissions(Collection<Submission> c) { for (Submission s : c) expansion s.review(); region … } Review paper • Upper pins: collection of submitted papers • Lower pins: collection of reviewed papers / SET / W&I 24-2-2014 PAGE 28 Expansion regions • How do we traverse the collection? <<concurrent>> Review paper Review paper a) Sequentially b) Concurrently • Reviewing scientific papers is done concurrently, so we chose solution b) / SET / W&I 24-2-2014 PAGE 29 Expansion regions • Each paper is reviewed and either rejected or accepted.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    71 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us