Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIFIED MODELING LANGUAGE(UML) BY Touseef Tahir Lecturer CS COMSATS Institute of Information Technology, Lahore.

Similar presentations


Presentation on theme: "UNIFIED MODELING LANGUAGE(UML) BY Touseef Tahir Lecturer CS COMSATS Institute of Information Technology, Lahore."— Presentation transcript:

1 UNIFIED MODELING LANGUAGE(UML) BY Touseef Tahir Touseeftahir@ciitlahore.edu.pk Lecturer CS COMSATS Institute of Information Technology, Lahore

2 Lecture Agenda  Activity Diagrams  Sequence Diagrams  Collaboration Diagrams

3 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

4 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

5

6 Activity Diagram

7

8 Branching A branch has one incoming transition and two or more outgoing transitions: Charge credit card Hold in will-callMail tickets [today  7 days before show] [today < 7 days before show]

9 Merging A merge has two or more incoming transitions and one outgoing transition: Customer sees show Mail tickets Customer picks up tickets

10 Forking A fork represents the splitting of a single flow of control into two or more concurrent flows of control: Receive order Process orderLog order

11 Joining A join represents the synchronization of two or more flows of control into one sequential flow of control: Pay bill Receive BillReceive product

12 Swimlanes Swimlanes partition groups of activities based on, for instance, business organizations: Pay bill Receive BillReceive product CustomerBilling

13

14 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.

15 Collaboration-Interaction-Message  Collaboration  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 collaboration  Interaction  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

16 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

17 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

18 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

19 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

20 Sequence Diagram  Activation  Execution of procedure including the time it waits for nested procedures to execute.  Shown by double line replacing part of lifeline

21 Sequence Diagram

22 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

23 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

24 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.

25 Sequence Diagram - Message  Message Frequency  Periodic Message is sent on regular, periodic basis  Aperiodic Message is not sent on a regular basis either sent once or at irregular point in time

26 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

27 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 

28 Class Exercise – Sequence Diagram

29 Cont. – Collaboration Diagram

30 Class Exercise  ATM (see Rose)

31 Collaboration Diagram  A collaboration diagram is an interaction diagram that emphasizes the organization of the objects that participate in the interaction.

32 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

33 Collaboration Diagram

34 Example  Car Lock system(Object Diagram)

35 Example

36  Collaboration Diagram

37

38 THANK YOU


Download ppt "UNIFIED MODELING LANGUAGE(UML) BY Touseef Tahir Lecturer CS COMSATS Institute of Information Technology, Lahore."

Similar presentations


Ads by Google