unified modeling language(uml) by

38
UNIFIED MODELING LANGUAGE(UML) BY Touseef Tahir [email protected] Lecturer CS COMSATS Institute of Information Technology, Lahore

Upload: nirav

Post on 23-Feb-2016

33 views

Category:

Documents


0 download

DESCRIPTION

Unified Modeling Language(UML) BY. Touseef Tahir [email protected] Lecturer CS COMSATS Institute of Information Technology, Lahore. Lecture Agenda. Activity Diagrams Sequence Diagrams Collaboration Diagrams. Activity Diagram. Intended to model workflows - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Unified Modeling Language(UML) BY

UNIFIED MODELING LANGUAGE(UML)BY

Touseef [email protected]

Lecturer CSCOMSATS Institute of Information

Technology, Lahore

Page 2: Unified Modeling Language(UML) BY

Lecture Agenda

Activity Diagrams Sequence Diagrams Collaboration Diagrams

Page 3: Unified Modeling Language(UML) BY

Activity Diagram Intended to model workflows An activity diagram in the use-case model

illustrates the flow of events of a use case Similar to traditional flowchart but permits

concurrent control in addition to sequential An activity is shown as a box with rounded ends

containing description of activity Simple completion transition are shown as arrows Branches are shown as guard condition or

diamond

Page 4: Unified Modeling Language(UML) BY

Activity Diagram Fork / Join / Synchronization bar If an activity has more than one output

value or successor control flow, arrows are drawn from the fork symbol

Multiple inputs are drawn to a join symbol

Swimlanes Organizing activities according to

responsibilities into groups

Page 5: Unified Modeling Language(UML) BY

NewState

Enter Pin

Verify Pin

Decision

Continue

incorrect

correct

Banking SystemATM

Process Order

Credit Account Ship order

fork

join

Notify Customer

Start

End

NewActivity5

Start

NewActivity

NewState

NewActivity2

NewActivity3

NewActivity4

WarehouseSalesCustomer

Page 6: Unified Modeling Language(UML) BY

Activity Diagram

Page 7: Unified Modeling Language(UML) BY
Page 8: Unified Modeling Language(UML) BY

BranchingA branch has one incoming transition and two or more outgoing transitions:

Charge creditcard

Hold in will-callMail tickets

[today 7 days before show] [today < 7 days before show]

Page 9: Unified Modeling Language(UML) BY

MergingA merge has two or more incoming transitions and one outgoing transition:

Customersees show

Mail tickets Customer picksup tickets

Page 10: Unified Modeling Language(UML) BY

ForkingA fork represents the splitting of a single flow of control into two or more concurrent flows of control:

Receive order

Process orderLog order

Page 11: Unified Modeling Language(UML) BY

JoiningA join represents the synchronization of two or more flows of control into one sequential flow of control:

Pay bill

Receive BillReceive product

Page 12: Unified Modeling Language(UML) BY

SwimlanesSwimlanes partition groups of activities based on, for instance, business organizations:

Pay bill

Receive BillReceive product

Customer Billing

Page 13: Unified Modeling Language(UML) BY

Start

Enter Card

Enter Pin

End

Select Withdraw Money

Read card

Display welcome Screen

Display menu

[ authorized ][ unauthorized ]

Enter Amount

Update Account

[ amount ok ]

Pay Cash

Eject card

Display insufficient message

amount not in account

ATM MachineCustomer

Page 14: Unified Modeling Language(UML) BY

Use Case Realization Specification

Describes the behavior or structure of something without determining how the behavior will be implemented.

Realize: To provide the implementation of a specific element

Realization: Relationship between a specification and implementation

Specification elements such as use case and interface are realized in collaboration or classes (implementation element)

A use case specifies externally visible functionality and behavioral sequences, but it does not supply an implementation.

A collaboration describes the objects that implement the use case behavior and the way that they will interact to do it. Usually one collaboration implements one use case.

Page 15: Unified Modeling Language(UML) BY

Collaboration-Interaction-MessageCollaboration

Description of a collection of objects that interact to implement some behavior within a context

An object may play more than one role in the same collaboration Has both structural and behavioral aspect Behavioral aspect is the set of messages exchanged by the object

bound to roles Also used to specify a software pattern / parameterized

collaborationInteraction

Set of messages within a collaboration A behavior that comprises a set of messages, exchanged among a

set of objects, to accomplish a specific purpose.Message

Communication between two objects Flow of control from a sender to a receiver May have parameters that convey values between the objects Adding message means adding responsibility to object receiving

message

Page 16: Unified Modeling Language(UML) BY

Interaction Diagrams

An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be exchanged between them

Shows step-by-step one of the flows through a use case So several interaction diagrams for one use case – one for each alternative

Contains lot of same details as in flow of events but the information is presented in a way more useful to the developers

Focused on objects that will be created to implement the functionality spelled out in use cases

Can show objects, classes or both. Model the dynamic aspect of the system Contain two sort of diagrams:

Sequence diagram Show the messages objects send to each other in a timely manner

Collaboration diagram Show the organization of the objects participating in an interaction

Page 17: Unified Modeling Language(UML) BY

Sequence versus Collaboration

Semantically both are the same Express different aspects of model Sequence diagram expresses time ordering Collaboration diagram is used to define class

behavior

Page 18: Unified Modeling Language(UML) BY

Finding Objects Objects

Something that encapsulates information & behavior One way is to look for nouns in flow of events Another good place is to look into scenario

documents A scenario is a specific instance of flow of events Example: ‘x’ withdraws money ; ‘x’ tries but pin is wrong Not all objects can be found in flow of events How objects interact in scenario are depicted in

interactions Scenario description in textual form is not part of UML. Its

interaction diagrams

Page 19: Unified Modeling Language(UML) BY

Sequence Diagram

A sequence diagram is an interaction diagram that emphasizes the time ordering of messages.

Each sequence diagram represents one of the flows through a use case Displays interaction as 2D chart Vertical dimension is the time axis, time proceeds down the page Horizontal dimension shows the classifier roles that represents individual

objects in the collaboration No significance of horizontal ordering of the object Lifeline

A vertical dashed line that represents the lifetime of an object. During the time an object exists, the role is shown by dashed line During the time an activation of the procedure on the object is

active the lifeline is drawn as a double line (focus of control) A message is shown as an arrow from the lifeline of one object to that of

another Each message represents one object making a function call to another Each message will become an operation later (in the class of that object) Message can be reflexive showing an object is calling one of its own operation The arrows are arranged in time sequence down the diagram

:AnObject

InsertCard

Page 20: Unified Modeling Language(UML) BY

Sequence Diagram Activation

Execution of procedure including the time it waits for nested procedures to execute.

Shown by double line replacing part of lifeline

Page 21: Unified Modeling Language(UML) BY

Sequence Diagram

Page 22: Unified Modeling Language(UML) BY

Additional Features Iteration

Consider an order which has several line items. When the order is cancelled, it must cancel each line items.

An interaction diagram for such a scenario could include multiple line item objects with the Order sending a cancel message to each of them

UML provide notation for multiple instance for interaction diagrams but Rose shows only in collaboration diagram

Order LineItem

1: cancel

Page 23: Unified Modeling Language(UML) BY

Interaction Diagrams – Object Props.

Object Persistence Persistent

Object will be saved to database or some other form of persistent storage. Implies that object will continue to exist even after the program has terminated

Static Object stays in memory until the program is terminated.

Implies that it lives beyond the execution of sequence diagram but is not saved to persistent storage

Transient Object stays in memory only for short time. For example

until the logic of sequence diagram has finished Multiple Instance

Rose option: like list of employees Separate icon to show multiple instances Rose uses single instance icon on sequence diagram

Page 24: Unified Modeling Language(UML) BY

Sequence Diagram - Message Message can be added by drawing an arrow between

the lifelines of two objects OR From an object’s lifeline to itself (reflexive) Message number can be shown as well (tools->options-

>diagram) Focus of control shows the period of time during which

an object is performing an action, either directly or through an underlying procedure.

The length of a FOC indicates the amount of time it takes for a message to be performed (only in SD).

When a message is moved vertically, each dependent message will move vertically as well.

Page 25: Unified Modeling Language(UML) BY

Sequence Diagram - Message Message Frequency

PeriodicMessage is sent on regular, periodic basis

AperiodicMessage is not sent on a regular basis either sent once or at irregular point in time

Page 26: Unified Modeling Language(UML) BY

Sequence Diagram - Message

Synchronization Simple

In sequential systems message passing is simple. Message runs in a single thread of control

Synchronous An operation commences only when the sender has initiated the action

and the receiver is ready to accept the message. Sender and receiver wait for each other until both are ready to proceed.

Asynchronous An operation commences regardless of whether the receiver is expecting

the message or not. Balking

Like synchronous, but the sender will abandon the operation if the receiver is not ready.

Time-out Like synchronous, but the sender will only wait a specific amount of time

for the receiver to be ready. Notes

Can be added to diagram (objects) to add comment without affecting code generation

Page 27: Unified Modeling Language(UML) BY

Class Exercise Consider a use case which describes making a phone call. The

caller initiates the use case and receiver is a secondary actor. The system the caller and receiver interact is the phone system. Consider a normal flow:

The use case begins when caller picks up the phone Caller listens for dial tone (Alternate: no dial tone) Caller dials a number Phone system rings receiver’s phone (alternate: wrong

number) Receiver answers (alternate: no answer) Caller conducts conversation The use case ends when caller hangs up phone

caller Make Telephone Call Receiver

Page 28: Unified Modeling Language(UML) BY

Class Exercise – Sequence Diagram

Caller Phone System Receiver

1: Picks up

2: dial tone

3: Dial number4: Ring

5: Picks up

6: converse 7: Converse

8: Hangup

Page 29: Unified Modeling Language(UML) BY

Cont. – Collaboration Diagram

Receiver

Caller

Phone System

1: Picks up

2: dial tone

3: Dial number

4: Ring

5: Picks up

6: converse

7: Converse

8: Hangup

Page 30: Unified Modeling Language(UML) BY

Class Exercise ATM (see Rose)

Page 31: Unified Modeling Language(UML) BY

Collaboration DiagramA collaboration diagram is an interaction diagram that

emphasizes the organization of the objects that participate in the interaction.

Page 32: Unified Modeling Language(UML) BY

Collaboration Diagram Models the objects and links that are

meaningful within an interaction A classifier’s role describes an object An association role describes a link Messages are shown as arrows attached to the

relationship lines connecting classifier roles Sequence of messages is indicated by

sequence numbers Shows parameters and local variables of

operation

Page 33: Unified Modeling Language(UML) BY

Collaboration Diagram

Page 34: Unified Modeling Language(UML) BY

Example Car Lock system(Object Diagram)

Page 35: Unified Modeling Language(UML) BY

Example

Page 36: Unified Modeling Language(UML) BY

Collaboration Diagram

Page 37: Unified Modeling Language(UML) BY
Page 38: Unified Modeling Language(UML) BY

THANK YOU