View
51
Download
0
Category
Tags:
Preview:
DESCRIPTION
Unified Modeling Language(UML) BY. Touseef Tahir Touseeftahir@ciitlahore.edu.pk 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
Citation preview
UNIFIED MODELING LANGUAGE(UML)BY
Touseef TahirTouseeftahir@ciitlahore.edu.pk
Lecturer CSCOMSATS Institute of Information
Technology, Lahore
Lecture Agenda
Activity Diagrams Sequence Diagrams Collaboration Diagrams
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
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
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
Activity Diagram
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]
MergingA merge has two or more incoming transitions and one outgoing transition:
Customersees show
Mail tickets Customer picksup tickets
ForkingA fork represents the splitting of a single flow of control into two or more concurrent flows of control:
Receive order
Process orderLog order
JoiningA join represents the synchronization of two or more flows of control into one sequential flow of control:
Pay bill
Receive BillReceive product
SwimlanesSwimlanes partition groups of activities based on, for instance, business organizations:
Pay bill
Receive BillReceive product
Customer Billing
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
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.
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
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
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
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
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
Sequence Diagram Activation
Execution of procedure including the time it waits for nested procedures to execute.
Shown by double line replacing part of lifeline
Sequence Diagram
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
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
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.
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
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
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
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
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
Class Exercise ATM (see Rose)
Collaboration DiagramA collaboration diagram is an interaction diagram that
emphasizes the organization of the objects that participate in the interaction.
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
Collaboration Diagram
Example Car Lock system(Object Diagram)
Example
Collaboration Diagram
THANK YOU
Recommended