Вы находитесь на странице: 1из 4

UML Tutorials

Introduction to the UML

The Unified Modeling Language (UML) is arguably the widest used tool today to develop systems. It is the
communication standard for the world of software development. It helps to define the boundaries of a system, its
structure and behaviour. UML can be used to model systems independent of the programming language platforms.

The systems in the aforementioned sentence means a combination of software and hardware that provides a
solution for a business problem. The gold standard in the industry for the design notation that the clients, analysts
and developers agree is the UML. This notation has been developed by three computer scientists Booch, Rumbaugh
and Jacobson.

In this starting tutorial we will directly jump into various diagrams and understand the intricacies, instead of long and
tiring sentences.

Components of the UML

The UML consists of graphical elements that are combined to form diagrams. The elements are combined using a set
of rules and the diagrams formed present a set of different views for a given system. This set of views is called the
model. The model describes what the system is supposed to do. The implementation details are not described in the

A model is a set of UML diagrams that we examine, assess and modify in order to understand and
develop a system.

In this tutorial section we introduce six UML notations with the help of the washing machine example:

Use case diagrams

Class diagrams
Object Diagrams
State diagrams
Sequence Diagrams
Activity Diagrams

Let us consider a washing machine and its functionalities to illustrate the use case diagram.

Use Case Diagram

A use-case can be defined as the behaviour of a system from the users perspective. During the requirements
elicitation (or requirement gathering) which is the practice of collecting the requirements of a system from
users, customers and other stakeholders, the use cases are used to represent the functionality of a system. Thus
the use cases focuses on the behaviour of a system from an external point of view.

An actor represents any entity that interacts with the system.

Page 1
Tutorial 1: Introduction to UML

Coming to the washing machine example as shown above, the washing machine is a system that is used by
people to wash clothes. Here the actor is obviously a person who uses the washing machine and the wash
clothes activity is the use-case.

The stick-like person on the left is the actor. The ellipse inside the rectangle represents the use-case. The
rectangle represents the system. The actor lies outside the rectangle.

Class Diagram

When we consider the washing machine as a thing we realise that it will have some characteristics or
properties and it will also exhibit certain behaviours. Converting this statement into the UML lingo, we can say
that things have attributes (properties) and behaviours (set of operations). The things can also be categorised.
For example, we have a set of 100 washing machines in a store or we have 200 packets of red-chilli powder in a
departmental store. Thus washing machines and the chilli powder packets constitute two different categories.
We can define any number of categories with specific objects. It is important to note, that the group of things
have the same attributes and same behaviours. For a washing machine, the attributes would be brand name,
model and capacity. The operations performed by a washing machine would be accept detergent powder,
accept clothes, turn on and turn off.

The above diagram depicts the class diagram notation that captures the attributes and the properties of a
washing machine. The rectangle is the icon that represents the class. It is divided into three areas. The
uppermost area consists of the name, the middle area consists of the attributes and the bottom area holds the

The class name WashingMachine consists of two words Washing and Machine. These two words are
joined together and the initial letter is capitalised. Similarly, if there are more than two words then the same
principle of capitalising the first letter of each word is done followed by the elimination of white spaces between
them. Attributes and operations also follow the convention. The only difference is that the first letter of the first
word is not capitalised for both attributes and operations. A pair of parentheses follows the name of operations.

Object Diagram

An object is an instance of a class a specific thing with specific values of the class attributes. The washing
machine may have a brand name Samsung, model WT82M4000HB and a capacity of 8.2 kg.
UML Tutorials

The icon represents the object in the UML. The icon is a rectangle where the name is underlined. Inside the
rectangle there are two names on either side of the colon (:). The name on the left is the name of the specific
instance of the object and the class name is on the right side of the colon. The name of the instance begins with
a lowercase letter. There is also another type of object called the anonymous object with no name. In this case
we show only the class name.

State Diagram

An object is always in a particular state. The washing machine is either off, soaking, spinning or rinsing states.
The washing machines states are depicted in the following diagram.

Sequence Diagram

The class diagrams and objects diagrams represent static information. But the systems are dynamic that keeps
changing states over time. The sequence diagrams depict the time-based changes inside a system as a two-
dimensional chart. Continuing with our washing machine analogy, we will consider the washclothes() use case.

We have added clothes and the detergent in the drum and turned on the machine to wash clothes. The total
time assumed for the entire washing process is say, 42 minutes. We will write a brief algorithm that depicts the
steps of washing below.

1. Soaking happens for 10 minutes after the water enters the drum via the water pipe. The drum remains
2. The end of soaking phase means that the water stops entering the drum and washing begins.
3. The drum rotates clockwise and anticlockwise for a period of 12 minutes.
4. Washing ends, the drum stops rotating and the soapy water is ejected from the drum.
5. Fresh water enters the drum via the water pipe and the process of rinsing begins.
6. The drum rotates back and forth for 10 minutes after which water entry stops.
7. The drum stops, pumps out water and rinsing ends.
8. The spinning process begins and goes on for 10 minutes during which the drum moves back and forth.
9. The spinning process ends and the drum rotation stops.
10. The washing process ends.

After going through the procedure, we can see that the timer, drum and water pipe are objects. These objects
operate in tandem by sending messages to each other. Each message is an information unit from the sender
object to the receiver object. Here the information unit means a request made by the sender to the receiver to
complete one of the receivers operations.

The timer can perform following operations: time the soaking, time the washing, time the rinsing and time the

The water pipe can perform the following operations: Start the flow of water, Stop the flow of water.

The drum can perform the following operations: store water, rotate clockwise, rotate anticlockwise, stop
rotation and pump water.

The 2D chart below depicts the three anonymous objects sending messages to and fro in a particular time
sequence. We will look at the building blocks of the sequence diagram in a later tutorial.

Activity Diagram
Tutorial 1: Introduction to UML

Let us consider only the steps of the rinsing operation from the above sequence of the washclothes()
operation of the washing machine. This diagram shows the flow of message from one activity to another. These
are similar to flowcharts and model the paths through the use-case.