lecture#08 sequence diagrams

37
By: Altaf Hussain SS KRL BS(CS), AU Peshawar, MS(CSE), NUST Islamabad

Upload: babak

Post on 14-Jun-2015

1.001 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Lecture#08 sequence diagrams

By: Altaf Hussain

SS KRLBS(CS), AU Peshawar, MS(CSE), NUST Islamabad

Page 2: Lecture#08 sequence diagrams

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
Page 4: Lecture#08 sequence diagrams
Page 5: Lecture#08 sequence diagrams

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

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
Page 8: Lecture#08 sequence diagrams

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
Page 10: Lecture#08 sequence diagrams
Page 11: Lecture#08 sequence diagrams
Page 12: Lecture#08 sequence diagrams
Page 13: Lecture#08 sequence diagrams
Page 14: Lecture#08 sequence diagrams
Page 15: Lecture#08 sequence diagrams
Page 16: Lecture#08 sequence diagrams
Page 17: Lecture#08 sequence diagrams
Page 18: Lecture#08 sequence diagrams
Page 19: Lecture#08 sequence diagrams
Page 20: Lecture#08 sequence diagrams

To support conditional and looping constructs UML use diagram/ interaction frames

Page 21: Lecture#08 sequence diagrams
Page 22: Lecture#08 sequence diagrams
Page 23: Lecture#08 sequence diagrams
Page 24: Lecture#08 sequence diagrams
Page 25: Lecture#08 sequence diagrams
Page 26: Lecture#08 sequence diagrams
Page 27: Lecture#08 sequence diagrams
Page 28: Lecture#08 sequence diagrams
Page 29: Lecture#08 sequence diagrams

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

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

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

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

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
Page 35: Lecture#08 sequence diagrams
Page 36: Lecture#08 sequence diagrams

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