lecture#08 sequence diagrams
TRANSCRIPT
![Page 1: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/1.jpg)
By: Altaf Hussain
SS KRLBS(CS), AU Peshawar, MS(CSE), NUST Islamabad
![Page 2: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/2.jpg)
Interaction diagram describes exemplary how groups of objects collaborate in some behaviors.
An interaction diagram typically captures the behavior of a single use case.
Interaction diagrams don’t capture the complete behavior, only typical scenarios.
There are two types of interaction diagrams:• Sequence diagrams emphasize the order or
concurrency of the interactions.• Collaboration diagrams emphasize the interacting
objects.
![Page 3: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/3.jpg)
![Page 4: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/4.jpg)
![Page 5: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/5.jpg)
Behavior of the “order” use case:• A customer orders several products.• The (sub-) orders (“order lines”) for each are
prepared separately.• For each product check the stock.
If the product is in stock, remove requested amount from stock.
If the product stock falls below a predefined level, reorder it.
Activity Diagram
![Page 6: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/6.jpg)
Objects and messages are taken from Class Diagram. The lifeline represents the object’s life during the
interaction. Messages are represented by arrows between
lifelines, labeled at minimum with the message name.
To send a message between objects, there has to be an association between the classes with in Class Diagram.
The sequence in which the messages occur is shown from top to bottom.
The iteration maker indicates that a message is sent many times to multiple receivers.
Condition represents whether a message is sent or not?
Self-delegation is used whenever an object sends message to itself.
![Page 7: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/7.jpg)
![Page 8: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/8.jpg)
Creation is whenever a new object appears below starting level.
Returns indicates the return of control after the message, not a new message.
![Page 9: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/9.jpg)
![Page 10: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/10.jpg)
![Page 11: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/11.jpg)
![Page 12: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/12.jpg)
![Page 13: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/13.jpg)
![Page 14: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/14.jpg)
![Page 15: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/15.jpg)
![Page 16: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/16.jpg)
![Page 17: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/17.jpg)
![Page 18: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/18.jpg)
![Page 19: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/19.jpg)
![Page 20: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/20.jpg)
To support conditional and looping constructs UML use diagram/ interaction frames
![Page 21: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/21.jpg)
![Page 22: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/22.jpg)
![Page 23: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/23.jpg)
![Page 24: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/24.jpg)
![Page 25: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/25.jpg)
![Page 26: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/26.jpg)
![Page 27: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/27.jpg)
![Page 28: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/28.jpg)
![Page 29: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/29.jpg)
UML offers diagram elements to show concurrent processes explicitly within interaction diagrams.
Activation Indicates whenever a method is active, Shows methods which are waiting for return
Asynchronous message Allow the creation of new thread or objects Communicates with already running threads or
objects Deletion
Occur by self destruction of threads or objects, Can be initiated by external message
![Page 30: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/30.jpg)
Example: A bank transaction transfers $100 from bank
account # 123 to # 456. Withdraw $100 from bank account # 123 Deposit $100 at bank account # 456
Withdraw & deposit may execute in parallel (concurrently).
The transaction is only successful if both sub-transactions (withdraw and deposit) are successful.
Therefore a transaction coordinate checks the successful completion of the concurrent sub-transactions.
Each time a sub-transaction completes successfully it checks if all other sub-transactions have been completed successfully. If this is the case, it reports success to its client.
If any sub-transaction fails, it cancels the other sub-transactions and reports failure to its client.
![Page 31: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/31.jpg)
Activation• An activation is a
method that is either executing or waiting for return (active method).
• Activation are also useful for describing self-delegation.
Asynchronous message• An asynchronous
message is a message that does not block the caller, i.e. caller and receiver execute concurrently.
![Page 32: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/32.jpg)
Activation• An activation is a
method that is either executing or waiting for return (active method).
• Activation are also useful for describing self-delegation.
Asynchronous message• An asynchronous
message is a message that does not block the caller, i.e. caller and receiver execute concurrently.
![Page 33: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/33.jpg)
Unnecessary detail may be suppressed. Remember that sequence diagrams are only scenarios and not a complete description of behavior.
Objects may be deleted explicitly by other objects or by themselves(self-destruction).
![Page 34: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/34.jpg)
![Page 35: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/35.jpg)
![Page 36: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/36.jpg)
Collaboration Diagram emphasizes the structure of objects interaction instead of the interaction sequence.
The sequence is given by number on the arrow instead of vertical order.
![Page 37: Lecture#08 sequence diagrams](https://reader036.vdocuments.us/reader036/viewer/2022062514/557d1869d8b42a3d3d8b4c4d/html5/thumbnails/37.jpg)