UML Diagrams in Software Development

All that is swell in UML.

Kristina Mancini
4 min readApr 25, 2023

Close your eyes and imagine your favorite place on Earth. It could be at a beach, in a canoe in the middle of a lake on a sunny afternoon, or the cheese department in a grocery store, you name it. Visualizing can make things easier and help shape an idea out of thought.

The software applications you use today were all created out of a simple thought. If you ever tried jumping into creating an application without visualizing its system design first, the software development process might get a little confusing. One thing that really helps visualize a project and reduce confusion in software development, particularly with object oriented programming, is a UML diagram.

UML stands for Unified Modeling Language. It is a form of a graphical notation. That notation can be divided into static modeling and dynamic modeling of elements. UML can consist of many different types of diagrams, but I will focus on the static modeling notation found in class relationship diagrams.

UML Class Diagrams

UML class diagrams really help structure and build the design of a system in object oriented software. This includes the system’s classes, objects, attributes, operations (or methods), and the relationship among them.

Class

A class is a definitive element in a class diagram. Multiple classes can appear in a UML diagram. The picture below shows a rough interpretation of what a class element would look like in a diagram. There would be a class name listed at the top row, the second row would list attributes with that class, and the third row would list any operations with the class.

diagram with three rows, one column. Says “Class Name” on top row, says “attribute” six times in middle row, and says “operation” six times in last row.
Made by me in Figma

Attributes

An attribute can give away more information about the class. The picture below represents a class named Shape with two attributes, and no operations. The first attribute is named width and the second attribute is named length.

diagram with three rows and one column, top row says “Shape”, middle row says width is private and is of type int and length is private with type int, last row is empty

The “-” in front of each attribute indicates the visibility of that attribute. Visibility can mean public(+), private(-) or protected(#). These attributes are considered private, and they are accessible within that class only. The “:” indicates the type of value that attribute is. These attributes are both of type int (or integer).

Operations

An operation help the class carry out specific duties when called. The picture below represents a class named shape with two attributes and two operations.

diagram with three rows and one column, top row says “Shape”, middle row says width is private and is of type int and legnth is private with type int, and last row shows two public operations called get width and get length both returning type int

Notice all the operations are public indicated by the “+”. The first operation is named getWidth and the second operation is named getLength. The “()” indicates any parameters that are passed into that operation. The “:” after indicates the return type of that operation, so a little bit different than an attribute. getWidth()’s return type is int, therefore when that operation is called it will return an integer.

Putting Everything Together

Putting everything together, we can create this:

shows three classes, the Shape class but with no attributes and one operation called get Area that returns a double, the Square class with a width attribute and two operations called get width and get area, and a Rectangle class with two attributes called width and length and three operations called get width, get length, and get area. the three classes are not connected by lines

This UML diagram is representing shapes, such as the square and the rectangle, under the class Shape. However, the last thing we need to do is relate these classes to each other.

Relationship Arrows

There are a number of ways classes in a UML diagram can relate to each other, usually indicated by special arrows:

six different arrows, indicating different relationships such as inheritance, association, realization, dependency, aggregation, and composition

Inheritance is a relationship between a general class element and a specific class element. We can say that a rectangle is a specific element of a shape that is a general element.

Association is a relationship between instances of a class, indicating more general relationships.

Realization is a relationship between a class and its implemented interface. The class may need to implement methods from its interface.

Dependency is a relationship where an object of a specific class uses an object of another specific class in its method.

Aggregation is a relationship where a class is a part of another class.

Composition is a relationship where a class is a part of another class, but one class cannot live by itself if its other class is gone.

Can you guess what relationship the diagram shows below?

The three class diagram from before except the square and rectangle class have an arrow connecting to the shape class, indicating inheritance.

If you guessed inheritance, then you are correct!

The Purpose of UML Diagrams

Communication. They communicate ideas, thoughts, components, or projects together. And if that was not more obvious, the word “language” is in the name. They help organize and build systems in software development.

Sources:

Martin, C. R. (n.d.). UML Tutorial: Part 1 — Class Diagrams. Retrieved April 25, 2023, from https://www.ccs.neu.edu/home/riccardo/courses/csu370-fa07/umlClassDiagrams.pdf

UML Class Diagram Tutorial. (n.d.). Visual Paradigm. Retrieved April 25, 2023, from https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/

Zeil, S. (2018, September 20). UML Class Relationship Diagrams. Retrieved April 25, 2023, from https://www.cs.odu.edu/~zeil/cs330/latest/Public/classDiagrams/index.html#class-relationship-diagrams

--

--

Kristina Mancini

I write about different topics in computer science and technology.