KEMBAR78
How To Draw Class Diagram | PDF | Use Case | Unified Modeling Language
0% found this document useful (0 votes)
83 views50 pages

How To Draw Class Diagram

This document provides instructions for creating and editing various elements in a UML class diagram using Visual Paradigm modeling software. It describes how to create classes, associations, attributes, operations, generalizations, dependencies, enumerations and more. It also covers formatting options like hiding/showing elements and customizing element presentations.

Uploaded by

Hailu Badye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views50 pages

How To Draw Class Diagram

This document provides instructions for creating and editing various elements in a UML class diagram using Visual Paradigm modeling software. It describes how to create classes, associations, attributes, operations, generalizations, dependencies, enumerations and more. It also covers formatting options like hiding/showing elements and customizing element presentations.

Uploaded by

Hailu Badye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

How to Draw Class Diagram?

A class diagram is a kind of UML diagram that shows the objects that are required and the
relationships between them. Since it provides detailed information about the properties and
interfaces of the classes, it can be considered as the main model and regard the other diagrams as
supplementary models.

Creating class diagram


Perform the steps below to create a UML class diagram in Visual Paradigm.

1. Select Diagram > New from the application toolbar.


2. In the New Diagram window, select Class Diagram.
3. Click Next.
4. Enter the diagram name and description. The Location field enables you to select a
model to store the diagram.
5. Click OK.

Creating class
To create a class in a class diagram, click Class on the diagram toolbar and then click on the
diagram.

Create class

A class will be created.

Class created

Creating association
To create an associated class in a class diagram:

1. Move your mouse pointer over the source shape.


2. Press on the Resource Catalog button and drag it out.
Using Resource Catalog

3. Release the mouse button at the place where you want the class to be created. If you want
to connect to an existing class, drop at that class. Otherwise, drop an the empty space
(either at the diagram background or container shape like package).
4. If you are connecting to an existing class, select Association from Resource Catalog. If
you are creating a new class, select Association -> Class from Resource Catalog. If you
want to create an aggregation or composition, select Aggregation -> Class or
Composition -> Class instead.

To create a class

5. If you are creating a new class, you should see the class now and it is connected to the
source shape. Enter its name and press Enter to confirm editing.

Associated class created

To edit multiplicity of an association end, right-click near the association end, select
Multiplicity from the popup menu and then select a multiplicity.
Edit multiplicity

To show the direction of an association, right click on it and select Presentation Options >
Show Direction from the pop-up menu.

Show direction

The direction arrow is shown beside the association.


Direction shown

Creating generalization
To create a subclass:

1. Move your mouse pointer over the superclass.


2. Press on the Resource Catalog button and drag it out.

Using Resource Catalog

3. Release the mouse button at the place where you want the subclass to be created. If you
want to connect to an existing class, drop at that class. Otherwise, drop an the empty
space (either at the diagram background or container shape like package).
4. If you are connecting to an existing class, select Generalization from Resource Catalog.
If you are creating a new class, select Generalization -> Class from Resource Catalog.

To create a subclass

5. If you are creating a new class, you should see the class now and it is connected to the
source shape with a generalization. Enter its name and press Enter to confirm editing.
Subclass created

Creating dependency from/to attribute/operation


You can also add a dependency from and/or to an attribute or operation in class. To create such a
dependency.

1. Select Dependency from the diagram toolbar.

Selecting Dependency

2. Press on the source shape or a class member.

To press on the source operation

3. Drag to the target shape, or a class member.

Dragging to target attribute

4. Release the mouse button to create the dependency.

Dependency created between an operation and a member


Creating attribute
To create attribute, right click the class and select Add > Attribute from the pop-up menu.

Create attribute

An attribute is created.

Attribute created

Creating attribute with enter key


After creating an attribute, press the Enter key, another attribute will be created. This method
allows you to create multiple attributes quickly and easily.

Create attribute with Enter key

Creating operation
To create operation, right click the class and select Add > Operation from the pop-up menu.
Create operation

An operation is created.

Operation created

Similar to creating attribute, you can press the Enter key to create multiple operations
continuously.

Showing just a parameter's type

When the name of a parameter starts with "unnamed_", its name will not be displayed in the
class shape, leaving the parameter type (if defined).

Unnamed parameter

Drag-and-Drop reordering, copying and moving of class


members
To reord a class member, select it and drag within the compartment, you will see a thick black
line appears to indicate where the class member will be placed.
Reorder class member

Release the mouse button, the class member will be reordered.

Class member reordered

To copy a class member, select it and drag to the target class while keep pressing the Ctrl key,
you will see a thick black line appears indicating where the class member will be placed. A plus
sign is shown beside the mouse cursor indicating this is a copy action.

Copy class member

Release the mouse button, the class member will be copied.

Class member copied

To move a class member, select it and drag to the target class, you will see a thick black line
appears indicating where the class member will be placed. Unlike copy, do not press the Ctrl key
when drag, the mouse cursor without the plus sign indicates this is a move action.

Move class member


Release the mouse button, the class member will be moved.

Class member moved

Selecting all class members


To select all members within a class, you can select any member first, and then press Alt-A to
select the rest.

Relating class members


Relationships such as dependency and generic connectors can be added between attribute and
operation of classes. To do this:

1. Select the type of relationship to be created, under the diagram toolbar.

Selecting Dependency

2. Move the mosue pointer over the source member.

Create a relationship from a class member

3. Press on it and hold the mouse button.


4. Drag to the target member.

Release mouse button on target class member


5. Release the mouse button to create the connector. While it looks like the connector is
connecting the classes but not the members, if you check its specification you can see that
the connector is indeed connecting the members.

Relationship created

Creating enumeration and adding enumeration literal


An enumeration is a special data type that consists of a pre-defined set of values, known as
enumeration literals. Here are some of the common examples:

 Color (RED, GREEN, BLUE)


 Orientation (NORTH, SOUTH, EAST, WEST)
 Switch (ON, OFF)

To create an enumeration in the uml diagram tool, select Enumeration from the diagram toolbar
and click on the diagram to create one.

Create an enumeration

To add an enumeration literal, right click on the enumeration class and select Add >
Enumeration Literal from the popup menu.

Add an enumeration literal


Then, enter the name of the literal and confirm editing.

Enumeration literal entered

Generalization set
A generalization set defines a particular set of generalization relationships that describe the way
in which a general classifier (or superclass) may be divided using specific subtypes. To define a
generalization set, select the generalizations to include, right click and select Generalization set >
Create Generalization Set... from the popup menu.

Create a generalization set

Name the set in the Manage Generalization Sets window, and confirm by pressing OK.
Name the generalization set

The selected generalizations are grouped. Adjust the connector to make the diagram tidy.

Adjust connector

Repeat the steps for other generalizations.


Generalization sets defined

Defining delegate method for class


When project's programming language is set to be Visual Basic or C#, it is possible to define
delegate method for classes. To define delete method, right click on the class and select
Stereotypes > Delegate from the pop-up menu.

Stereotype class as Delegate

Hiding (and showing) attributes and operations


Per workspace

This applies to new classes that will be created in a project opened in specific workspace. To
change the setting:

1. Select Window > Project Options from the toolbar to open the Options window.
2. Click Diagramming on the list.
3. Open the Class tab.
4. Click Presentation tab.
5. Change the settings for Show attribute option and/or Show operation option.
Show or hide operations

Per diagram

This applies to classes in specific diagram. To change the setting:

1. Right click on the class diagram to set the option.


2. Select Presentation Options > Attribute Display Options / Operation Display
Options from the pop-up menu.
3. Select Hide All / Show All / Show Public Only.

Change the operations' presentation options for classes in diagram


Per class

This applies to specific class. To change the setting:

1. Right click on the class to set the option.


2. Select Presentation Options > Attributes / Operations from the popup menu.
3. Select Hide All / Show All / Show Public Only.

Change the operations' presentation options for a class

For specific attribute/operation

Instead of showing or hiding all members or public members, you may show/hide specific class
member per class. To do this:

1. Right click on the class to set the option.


2. Select Presentation Options > Attributes / Operations > Customized... from the pop-
up menu.
Show or hide specific class member

3. Select Customized under the drop down menu of Show.

Select Customized in window

4. Select the member(s) to hide and click > to hide them.


Select attributes to hide

5. Click OK button to confirm.

Setting initial (default) value for attribute


Initial value can be set to an attribute, indicating the default value of the attribute when the
owning object is instantiated. You can give a text value for initial value, or select an attribute of
another class. To set initial value to an attribute:

1. Open the specification window of attribute by right clicking on the attribute and selecting
Open Specification... from the popup menu.

Opening the attribute specification

2. In the General page of the specification window, enter the initial value in initial value
field if it is a text value, or popup the drop down menu to select a public and static field
of any class to be the value.
Selecting an initial value
In order to select the attribute of another class to be the default value, make sure
NOTE
the attribute you want to select is static (i.e. set to be in classifier scope) and is
:
public (so that other classes can access).

4. Click OK to confirm.

Setting the ownership of association end


Ownership of association ends by an associated class may be indicated by a small dot. To set the
ownership, right click at the association end where you want to set ownership, select Owned by
in the popup menu, then select either the association or the class at the opposite end. By selecting
class, the small dot will be shown.

Association end with ownership set


Subsetting on association end
Take a look at the sample below. The subset on d indicates that the collection d, which is an
instance of class C, is a subset of the collection b, instance of class A.

Subsetting on association end

To define a subset on an association end:

1. Right click on the association (where the subset end exist) and select Open
Specification... from the popup menu.
2. In the General tab, locate the association end where you want to define a subset. Click on
... for the Role property of the association end.
3. In the Association End Specification, open the Subsetted Association Ends tab.
4. From the list on the left hand side, click on the role you want to define subset for. Click >
to select it. If you do not see any role listing there, make sure your model respect the
pattern similar to the class diagram above - The class of both association ends are
subclasses, and there is an association connecting their superclasses.
5. Click OK to confirm and close the Association End Specification window.
6. Click OK to confirm and close the Association Specification window.
7. Right click on the association end and select Presentation Options > Show Association
End Property Strings from the popup menu to show the subset.

Related Resources
The following resources may help you to learn more about the topic discussed in this page.

 What is Class Diagram? - An introductory guide to Class Diagram


 New to Visual Paradigm? We have a lot of UML tutorials written to help you get started
with Visual Paradigm
 Visual Paradigm on YouTube
 Visual Paradigm Know-How - Tips and tricks, Q&A, solutions to users' problems
 Contact us if you need any help or have any suggestion
Create a UML deployment diagram
Visio Plan 2 Visio Plan 1 Visio Professional 2021 Visio Professional 2019

You can create a UML Deployment diagram to show the architecture of a deployment of
software artifacts to nodes. First, you open the UML Deployment template and pick one of the
four template options. Then the UML Deployment stencil appears, along with shapes that
conform to the UML 2.5 standard.

DesktopWeb

Start a UML Deployment diagram

1. Start Visio. Or if you have a file open already, click File > New.
2. Go to Categories > Software and Database > UML Deployment.
3. Select the blank template or one of the three starter diagrams. When you’ve picked the
template you want, click Create.
4. You should see the Shapes window next to the diagram. If you don’t see it, go to View >
Task Panes and make sure that Shapes is selected. If you still don’t see it, click the
Expand the Shapes window button on the left.
5. On the View tab, make sure the check box next to Connection Points is selected. This
will make connection points appear when you start connecting shapes.
6. Now, drag shapes you want to include in your diagram from the Shapes window to the
page. To rename text labels, double-click the labels.

Node instances and artifacts


When to use
1. Use Node Instance shapes when you want to specify an instance of a run-time
computational or physical device.
2. Put Artifact Instance shapes inside node instance shapes to deploy artifacts.

Step 1

Drag a Node Instance shape to the page first, and then make it bigger by dragging the shape
handles.

Step 2

Drag an Artifact Instance shape and place it inside the larger node shape. When you see a green
highlight, this means the smaller shape will be contained within the larger node shape. From that
point forward, when the node shape moves, the artifact inside will move as well.
Other container shapes
There are other container shapes available in the UML Deployment stencil. They behave like
the Node Instance shape. That is, when you drop shapes on top of them, the shapes are glued and
will move with the container. Here are some of the most popular container shapes for
deployment diagrams:

Hierarchical nodes

Nest node shapes inside each other when you want to show them hierarchically.
Package shapes

Use Package shapes when you need to represent containing elements like a folder.

Diagram Overview

Use the Diagram Overview shape when you want to surround all of the shapes with a frame.
Tips for connectors
Straighten connectors

If a connector is taking too many turns, right-click it, and then click Straight Connector.

Show multiplicity

If needed, right-click the connector and select Show Multiplicity. When you’re done, four text
boxes appear where you can add details. If you do not need all the text boxes, delete the ones you
don’t need.

Change connector type

You can change a connector type. For example, you can change from an Association to a
Directed Association. Right-click the connector, and then click Set Connector Type.

Make dynamic connections instead of point connections

If you anticipate moving shapes a lot, consider making a dynamic connection instead of a point
connection.

Move or rotate text on connectors

Most likely you’ll need to rotate or move text on your connector lines. Here’s how to do that:

1. Click an empty area of the page to deselect anything that may be selected.
2. On the Home tab, in the Tools group, click the Text Block tool
3. Click the connector that has text your want to rotate or move.
4. Drag the text block to move it, or rotate it using the Rotation Handle
5. When you’re done, click the Pointer Tool button

After you switch back to the Pointer Tool button , the text keeps the same position
relative to the shape. If you use the Pointer Tool to drag the text, the shape will also
move. To move the text independently of the shape, go back to the Text Block Tool .

Component shapes
When to use

Use component shapes for each functional unit in your system or application.
Show or hide stereotype

Right-click the shape to show or hide the stereotype label.

Interface shapes
When to use

1. Use the Provided Interface shape when you want to specify the realization of a
class/interface.
2. Use the Required Interface when you want to specify a dependency on a class/interface.

Step 1

Drag a Provided Interface shape to the page, and line up the port square with a connection
point. You know it’s connected when you see the green highlight around the connection point.
Step 2

Drag a Required Interface shape to the page, and line up the port square with a connection
point as well. You know it’s connected when you see the green highlight around the connection
point.

Step 3

To connect both a Provided and Required interface together, first select the Required Interface
shape. Then look for the yellow handle.

Step 4

Drag the yellow handle to connect with the Provided Interface.


Create a UML component diagram
Visio Plan 2 Visio Plan 1 Visio Professional 2021 Visio Professional 2019 More...

You can create a UML component diagram to show components, ports, interfaces and the
relationships between them.

A component in UML represents a modular part of a system. The behavior is defined in terms of
required and provided interfaces. A component has an external view with public properties and
operations, and it has an internal view with private properties and realizing classifiers. The
internal view shows how external behavior is realized internally.

Newer versionsWeb2007–2010

First, you open the UML Component template and pick one of the four options. Then the UML
Component stencil appears, along with shapes that conform to the UML 2.5 standard.

Note: The UML Component stencil is only available if you are a Visio Plan 2 subscriber. If you
have a subscription, make sure you have the latest version of Visio.

Start a component diagram

1. Start Visio. Or if you have a file open already, click File > New.
2. Go to Categories > Software and Database > UML Component.
3. Select the blank template or one of the three starter diagrams. When you’ve picked the
template you want, click Create.
4. You should see the Shapes window next to the diagram. If you don’t see it, go to View >
Task Panes and make sure that Shapes is selected. If you still don’t see it, click the
Expand the Shapes window button on the left.
5. On the View tab, make sure the check box next to Connection Points is selected. This
will make connection points appear when you start connecting shapes.
6. Now, drag shapes you want to include in your diagram from the Shapes window to the
page. To rename text labels, double-click the labels.

Component shapes

When to use

Use component shapes for each functional unit in your system or application.

Show or hide stereotype

Right-click the shape to show or hide the stereotype label.

Subsystems

You can use the component shape as a subsystem shape that contains other components. Just
resize it to be larger, and drop other components on top of it. When you see the green highlight,
let go. From that point on the larger shape will act as a container, and the smaller shape will
move with it.
Tip: If a component disappears after dragging it on top of another component, then bring it to the
front by pressing CTRL+SHIFT+F.

Interface shapes

When to use

1. Use the Provided Interface shape when you want to specify the realization of a
class/interface.
2. Use the Required Interface when you want to specify a dependency on a class/interface.

Step 1

Drag a Provided Interface shape to the page, and line up the port square with a connection
point. You know it’s connected when you see the green highlight around the connection point.

Step 2
Drag a Required Interface shape to the page, and line up the port square with a connection
point as well. You know it’s connected when you see the green highlight around the connection
point.

Step 3

To connect both a Provided and Required interface together, first select the Required Interface
shape. Then look for the yellow handle.

Step 4

Drag the yellow handle to connect with the Provided Interface.

Tips for connectors

Straighten connectors

If a connector is taking too many turns, right-click it, and then click Straight Connector.

Show multiplicity

If needed, right-click the connector and select Show Multiplicity. When you’re done, four text
boxes appear where you can add details. If you do not need all the text boxes, delete the ones you
don’t need.
Change connector type

You can change a connector type. For example, you can change from an Association to a
Directed Association. Right-click the connector, and then click Set Connector Type.

Make dynamic connections instead of point connections

If you anticipate moving shapes a lot, consider making a dynamic connection instead of a point
connection.

Move or rotate text on connectors

Most likely you’ll need to rotate or move text on your connector lines. Here’s how to do that:

1. Click an empty area of the page to deselect anything that may be selected.
2. On the Home tab, in the Tools group, click the Text Block tool
3. Click the connector that has text your want to rotate or move.
4. Drag the text block to move it, or rotate it using the Rotation Handle
5. When you’re done, click the Pointer Tool button

After you switch back to the Pointer Tool button , the text keeps the same position
relative to the shape. If you use the Pointer Tool to drag the text, the shape will also
move. To move the text independently of the shape, go back to the Text Block Tool .

Create a UML sequence diagram


Visio Plan 2 Visio Plan 1 Visio Professional 2021 Visio Professional 2019 More...

A UML sequence diagram shows how a set of objects interact in a process over time. It shows
the messages that pass between participants and objects in the system, and the order in which
they occur.
Newer desktop versionsWeb2007–2010

To build a sequence diagram, use a UML Sequence template or starter diagram, which includes
the UML Sequence stencil. Drag shapes from the stencil onto the drawing canvas to build the
diagram.

Start a sequence diagram

1. Start Visio. Or if you have a file open already, click File > New.
2. In the Search box, type UML sequence.
3. Select the UML Sequence diagram.
4. In the dialog box, select the blank template or one of the three starter diagrams. (A
description of each one is shown on the right when you select it.) Then select either
Metric Units or US Units.
5. Select Create.
6. The diagram opens. You should see the Shapes window next to the diagram. If you don’t
see it, go to View > Task Panes and make sure that Shapes is selected. If you still don’t
see it, click the Expand the Shapes window button on the left.
7. On the View tab, make sure the check box next to Connection Points is selected. This
option makes connection points appear when you start connecting shapes.
8. Now, drag shapes you want to include in your diagram from the Shapes window to the
page. To rename text labels, double-click the labels.

Lifelines for actors and objects

Use an Actor lifeline shape for each participant, and an Object lifeline shape for each system
component in your process.

Tip: As you drag the lifelines into place, green alignment guides appear onscreen to help you
line up and space the lifelines relative to the other lifeline shapes.

 Double-click in the heading box for each lifeline to enter a name or title.
 To lengthen or shorten a timeline, click the lifeline, then drag the yellow control point at
the bottom of the lifeline.

Messages

Use message shapes to represent information being sent between lifelines.

Tip: Visio helps you glue the message endpoints to each lifeline. A green circle appears at the
endpoint when it glues to a connection point. The connections points disappear when you are
done dragging.

 Attach the beginning endpoint to the lifeline sending the message, then drag the head
endpoint to the lifeline receiving the message.
 Double-click the message shape to create a text box, and type a name for the message.
 Use a Message shape (a solid line) to represent a request or the transmitting of
information.
 Use a Return Message shape (a dashed line) to represent a response to a prior message.
 Use a Self Message to represent a recursive call of an operation, or one method calling
another method belonging to the same object.
 Use the Asynchronous Message shape to show when an action might not happen
immediately.
 To change the shape of a connector message:
a. Right-click the connector.
b. At the bottom of the pop-up menu, select from the three options (Right-Angle,
Straight, Curved).
c. Click and drag the connector to change its shape.

Fragments
If one or more interactions form a loop, or require a condition to be met to end the interaction,
enclose those interactions in a fragment shape:

 Use the Loop fragment for a basic repeating interaction.


 Use the Optional fragment for steps that are only performed if a certain condition is
met.
 Use the Alternative fragment shape for an if-then or if-then-else process or interaction.
The fragment comes with two sections, which let you show the alternative interaction. To
add another condition, drag an Interaction operand onto the shape.

 Drag the fragment shape to the interactions it relates to. Use the sizing handles on the
fragment shape to ensure it encloses all of the related interactions.
 Double-click in the title corner of the fragment shape to add a title or short description of
the process enclosed by the fragment. Below the title corner, click the [parameters]
prompt if you want to enter the conditions that would end that process.

Activation

Place an Activation bar shape on a lifeline to show when and for how long that object or
participant is active in the process. Typically, there will be arrows going to and from an
activation box to demonstrate the flow of information.

Drag the endpoints of the Activation bar up or down to make it the length that you want.
Destruction

Destruction indicates when an object or actor is done participating in a system. A large X


appears at the end of its lifeline. To show destruction of an object in a diagram:

 Right-click the object, and select Show Destruction.

How to Draw an Activity Diagram in UML?


 How to Draw an Activity Diagram in UML?
 Steps to develop Activity Diagrams
 Creating an Activity Diagram

Activity Diagrams consist of activities, states and transitions between activities and states which
describe how activities are coordinated to provide a service, such as, how the events in a single
use case relate to one another, or how a collection of use cases coordinate to create a workflow
for an organisation

Steps to develop Activity Diagrams


The steps below outline the major steps to take in creating a UML Activity Diagram.

1. Finding system Actors, Classes and use cases


2. Identifying key scenarios of system use cases
3. Combining the scenarios to produce comprehensive workflows described using activity diagrams
4. Where significant object behavior is triggered by a workflow, adding object flows to the
diagrams
5. Where workflows cross technology boundaries, using swimlanes to map the activities
6. Refining complicated high level activities similarly, nested activity diagrams

Creating an Activity Diagram


1. Click New > New Diagram form the toolbar.

2. In the New Diagram window, select Activity Diagram, then click Next. You can use the search
bar above to filter diagrams.

3. Name the diagram, then click OK. In this tutorial, the diagram will be named Activity Diagram
Tutorial. You will then see an empty diagram.
4. Select Vertical Swimlane, then click any empty space on the diagram.

If you cannot findVertical Swimlane, try click the small triangle next to Horizontal Swimelane,
you will then see Vertical Swimlane.

5. You can rename partitions by double clicking the name of each partition. The first two
participants in this tutorial are Customer and Sales.

6. To create more partitions, right click any empty space on the swimlane, then select Add Vertical
Partition.

7. Repeat step 6 for more partitions.


8. Create the initial node by selecting Initial Node, then click on the participant where you want
the activity starts. In this tutorial, we would like like the activity starts from the Customer
participant.

9. To create an action, click the initial node, click and hold the resource button, then drag to the
desire location. When release the button, choose Control Flow > Action. You can rename the
action afterwards by double clicking the action.

10. Create more activities using step 9.


11. When creating a decision node, click action that you would like to connect with (Contracts
Agents Reviews Order in this example) , click and hold the resource button, then drag to the
desire location and release. Choose Control Flow > Decision Node on the popup window. You
are allowed drag and move the caption of a decision node.
12. Repeat step 11 when creating more decision nodes.
13. To create an activity final node, select the final action (Log Shipment in this case) , click the
resource button, then drag to the desire position and release. Choose Control Flow > Activity
Final Node on the popup window.
14. You will see something similar when finishing your diagram:
How to Draw a State Machine Diagram in
UML?
 How to Draw a State Machine Diagram in UML?
 State diagram at a glance
 Key concepts
 State
 Event
 Transition
 Action
 Creating a State Machine Diagram

A state machine Diagram (or start diagram, also called state chart of state transition diagram) is a
behavior which specifies the sequence of states an entity (or object) visits during its lifetime in
response to events, together with its responses to those events.

State diagram at a glance

Key concepts
State

A state is a condition during the life of an object during which it satisfies some condition,
performs some activity, or waits for some external event

Event

An event is the specification of a significant occurrence. For a state machine, an event is


the occurrence of a stimulus that can trigger a state transition.
Transition

A transition is a relationship between two states indicating that an object in the first state will,
when a specified set of events and conditions are satisfied, perform certain actions and enter the
second state.

Action

An action is an executable, atomic (with reference to the state machine) computation. Actions
may include operations, the creation or destruction of other objects, or the sending of signals to
other objects (events).

Creating a State Machine Diagram


1. Select Diagram > New from the tool bar.

2. In the New Diagram window, select State Machine Diagram, then click Next. you can use the
search bar above to filter results.
3. Name the diagram, then click OK. In this tutorial, we will name the diagram State Machine
Diagram Tutorial.

4. You will now see an empty diagram with an initial pseudo state.
5. To Create a new state, click the initial state, then drag the resource button to the desire
position and release. When release the button, choose Transition -> State from the popup
window. Once the state is created, you may change the name of the state.

6. Repeat step 5 for more states.


7. No you may see the transitions are not named. You can name a transition by double clicking the
transition. This example will name the transition between Available and Locked to Lock.

8. Once all the states are created, you may want to set up more transitions. You can do this by
selecting Transition, click and hold on the starting state (Sold in this example), then drag to the
destination state (Available in this example) and release. Do not forget to name the transition.

9. You are expected to see a diagram like this when you finish your diagram:

Why Use-Case diagram?


A Use Case consists of use cases, persons, or various things that are invoking the features called
as actors and the elements that are responsible for implementing the use cases. Use case
diagrams capture the dynamic behaviour of a live system. It models how an external entity
interacts with the system to make it work. Use case diagrams are responsible for visualizing the
external things that interact with the part of the system.

Use-case diagram notations


Following are the common notations used in a use case diagram:

Use-case:

Use cases are used to represent high-level functionalities and how the user will handle the
system. A use case represents a distinct functionality of a system, a component, a package, or a
class. It is denoted by an oval shape with the name of a use case written inside the oval shape.
The notation of a use case in UML is given below:

UML UseCase Notation

Actor:

It is used inside use case diagrams. The actor is an entity that interacts with the system. A user is
the best example of an actor. An actor is an entity that initiates the use case from outside the
scope of a use case. It can be any element that can trigger an interaction with the use case. One
actor can be associated with multiple use cases in the system. The actor notation in UML is given
below.

UML Actor Notation

How to draw a use-case diagram?


To draw a use case diagram in UML first one need to analyse the entire system carefully. You
have to find out every single function that is provided by the system. After all the functionalities
of a system are found out, then these functionalities are converted into various use cases which
will be used in the use case diagram.

A use case is nothing but a core functionality of any working system. After organizing the use
cases, we have to enlist the various actors or things that are going to interact with the system.
These actors are responsible for invoking the functionality of a system. Actors can be a person or
a thing. It can also be a private entity of a system. These actors must be relevant to the
functionality or a system they are interacting with.

After the actors and use cases are enlisted, then you have to explore the relationship of a
particular actor with the use case or a system. One must identify the total number of ways an
actor could interact with the system. A single actor can interact with multiple use cases at the
same time, or it can interact with numerous use cases simultaneously.

Following rules must be followed while drawing use-case for any system:

1. The name of an actor or a use case must be meaningful and relevant to the system.
2. Interaction of an actor with the use case must be defined clearly and in an understandable
way.
3. Annotations must be used wherever they are required.
4. If a use case or an actor has multiple relationships, then only significant interactions must
be displayed.

Tips for drawing a use-case diagram


1. A use case diagram should be as simple as possible.
2. A use case diagram should be complete.
3. A use case diagram should represent all interactions with the use case.
4. If there are too many use cases or actors, then only the essential use cases should be
represented.
5. A use case diagram should describe at least a single module of a system.
6. If the use case diagram is large, then it should be generalized.

An example of a use-case diagram


Following use case diagram represents the working of the student management system:
UML UseCase Diagram

In the above use case diagram, there are two actors named student and a teacher. There are a total
of five use cases that represent the specific functionality of a student management system. Each
actor interacts with a particular use case. A student actor can check attendance, timetable as well
as test marks on the application or a system. This actor can perform only these interactions with
the system even though other use cases are remaining in the system.

It is not necessary that each actor should interact with all the use cases, but it can happen.

The second actor named teacher can interact with all the functionalities or use cases of the
system. This actor can also update the attendance of a student and marks of the student. These
interactions of both student and a teacher actor together sums up the entire student management
application.

When to use a use-case diagram?


A use case is a unique functionality of a system which is accomplished by a user. A purpose of
use case diagram is to capture core functionalities of a system and visualize the interactions of
various things called as actors with the use case. This is the general use of a use case diagram.

The use case diagrams represent the core parts of a system and the workflow between them. In
use case, implementation details are hidden from the external use only the event flow is
represented.

With the help of use case diagrams, we can find out pre and post conditions after the interaction
with the actor. These conditions can be determined using various test cases.

In general use case diagrams are used for:

1. Analyzing the requirements of a system


2. High-level visual software designing
3. Capturing the functionalities of a system
4. Modeling the basic idea behind the system
5. Forward and reverse engineering of a system using various test cases.

Use cases are intended to convey desired functionality so the exact scope of a use case may vary
according to the system and the purpose of creating UML model.

Summary
 Use case diagrams are a way to capture the system’s functionality and requirements in
UML diagrams.
 It captures the dynamic behavior of a live system.
 A use case diagram consists of a use case and an actor.
 A use case represents a distinct functionality of a system, a component, a package, or a
class.
 An actor is an entity that initiates the use case from outside the scope of a use case.
 The name of an actor or a use case must be meaningful and relevant to the system.
 A purpose of use case diagram is to capture the core functionalities of a system.

You might also like