UML Class Diagram Discussion: Complete Guide with Examples

This article contains the complete discussion about What is UML Class Diagram. It will give you better understanding about UML Class Diagram, its visibility and relationships between classes. You will be guided on how to build and design your UML Class Diagram by walking through the provided examples and explanation below.

You should know that the Class Diagram is one of the UML (Unified Modeling Language) Diagrams. UML diagrams are used to emphasize the systems’ behaviors and structures before developing them. They also serves as guide to the software developers, teaching on how should they create the systems.

The primary goal of UML is to establish a standard for visualizing the design of a system. It’s very similar to plans used in other engineering professions. UML diagrams are very useful not just for developers but also to you. So it is an advantage for you to learn the Class Diagram.

What is meant by UML Class Diagram?

UML Class Diagrams are used to describe classes and their relationships in software design and modeling. The diagram depicts the names and attributes of the classes, as well as their links and, in some cases, their methods. It is similar to a flowchart in which classes are represented as boxes with three rectangles inside each box. The top rectangle has the class’s name; the middle rectangle contains the class’s properties; and the bottom rectangle contains the class’s methods, commonly known as operations.

A class diagram Also depicts a class’s attributes and operations, as well as the system’s limitations. Because class diagrams can be directly mapped with object-oriented languages, they are frequently utilized in the modeling of object-oriented systems.

In order for you to create Class Diagram, you must know first its relationships and visibility symbols. These relationships and symbols will help you in designing the class diagram. They will also guide you emphasizing the structure of classes that you will apply to your system.

Basic Relationships and Symbols used in UML Class Diagram:

All programmers and developers must understand and learn how to create a Class Diagram. It is because designing class diagram will direct you on how you deal with the classes included in your system. This strategy will also help you avoid repetition when developing the system.

UML Class Diagram Main Components:

There are three sections to a standard class diagram. The class name appears in the upper portion. Whether you’re talking about the classifier or an object, this portion is always essential. The class’s attributes are found in the middle portion and the Class operations are included in the bottom part (methods).

  1. UML Class Diagram – Class Name

    UML Class Diagram - Class Name
    It represents the things present in the system. Whether you’re talking about the classifier or an object, this portion is always essential. The name of the class is written in the top compartment. The initial letter is capitalized and printed in bold and centered.

  2. UML Class Diagram – Attributes

    UML Class Diagram - Class Attributes
    A data definition for a classifier instance is represented by an attribute. For that data definition, an attribute describes a range of values. The classifier can have as many attributes as it wants or none at all. Attributes are used to describe the structure and value of a class instance. It contains the values that describes each instances.

    The class’s attributes are stored in this partition of the box. This section is used to describe the class’s characteristics. When specifying a specific instance of a class, this is required. It can be represented by fields, variables and properties.

  3. UML Class Diagram – Methods or Operations

    UML Class Diagram - Class Methods or Operations
    Methods in UML Class Diagram is also known as operations or functions. It allows you to specify any behavioral feature of a class. These are short snippets of code that interact with attributes. The properties are listed directly below the name, while the methods are shown at the bottom.

    It’s a set of services that the class offers. After the colon at the end of the method signature, the return type of the method is displayed. After the colon following the parameter name, the return type of method parameters is also displayed.

UML Class Diagram Visibility and their Symbols

Here are the Visibility Symbols used in creating the UML Class Diagram. They will help you on how would you explain the structure of a class in system development. By using these visibility symbols, you’ll be able to differences and certainty of classes in a Class Diagram.

  • Private: This UML Class diagram visibility is represented by a minus (-) symbol. This visibility symbol can’t be accessed by any other class or subclasses. Here’s the UML Class Diagram example format for the private visibility.
    UML Class Diagram - Private Visibility
  • Public: The public visibility is represented by a plus (+) symbol. It can be accessed by any other class or subclasses. And its example UML Class Diagram format is here:
    UML Class Diagram - Public Visibility
  • Protected: It is one of the class diagram visibility that can be accessed the same class or subclasses. it is represented by the hash (#) symbol. We also provided here the example format for UML Class Diagram Protected Visibility.
    UML Class Diagram - Protected Visibility
  • Tilde: The Tilde visibility symbol means that the class can be used as long as its in the same package. It is represented by this (~) symbol. And this is the example UML Class Diagram format for it.
    UML Class Diagram - Tilde Visibility

UML Class Diagram Relationships

Now here are the Relationship that your should learn before designing the UML Class Diagram. They were given meaning according to their role in the system’s class diagram illustration. They were also given example below to give give you clear Explanation or their roles and definition.

  • Inheritance: This UML Class Diagram Relationship is used instead of duplicating the attributes to apply them for the subclasses. You can apply the attributes of the superclass or the parent class into its subclasses. And here is the example formation when applying the UML Class Diagram Inheritance.
  • UML Class Diagram - Inheritance Example
    It is specified using the arrow symbol. This given example for the UML Class Diagram shows that the attributes declared in the parent class (user) can be inherited by the child classes. You don’t have to declare the attributes for both subclasses or child class. This makes your work more easier and clear to understand.
  • Association: The Association uses a simple line between two classes to emphasize the UML Class Diagram relationship. This illustrates that there is association between classes but there’s no dependency. And here’s the example illustration for this king of UML Class Diagram Relationship.
    UML Class Diagram - Association Example
    It uses a simple line to specify the relationship between the classes. This kind of relationship doesn’t have dependency or inheritance but they was just associated to complete a task. The example for UML Class Diagram association lets you create associations in your project.
  • Aggregation: This UML Class Diagram Relationship uses an open diamond symbol. It is a special type of relationship that specifies a whole and its parts. Aggregation conveys that a class or a subclass can exist outside a whole. To give you more enlightenment, here’s the Class Diagram example on how to design UML using Aggregation.
    UML Class Diagram - Aggregation Example
    Here’s the explanation on how the given example for UML Class Diagram works. The aggregation relationship means that a class can be a part of another class. Its just that the class can also be whole without the other class. In short, Aggregation relationship shows options and the class can be part of a group but can also left the group.
  • Composition: While the aggregation relationship can exist outside a whole, the Composition can’t. That is because, every class or subclasses is composed of another class. In short, they can’t function without the other/s. It is represented by this ____ symbol.
    UML Class Diagram - Composition Example
    This example shows that if the class was destroyed, another class or the subclass will also be destroyed or the whole UML Diagram will not work. A simple scenario would be: the child or subclass can’t exist without its parent or superclass.
  • Multiplicity: Now the Multiplicity relationship was not represented by symbols but by numbers. This allows you to set numerical constraints on the Class Diagram.
    UML Class Diagram - Multiplicity Example
    The UML Class Diagram Example means that you can declare the limitations of users, or participants in a certain class. I will be giving you example format of these numerical constraints that you use.
    Types of Multiplicity:
    – Zero to one (0…1) means optional
    – N (n) means that a number needs to be specified.
    – Zero to many (0…*) means that the multiplicity can be zero up to multiple.
    – One to many (0…*) means that the multiplicity can be multiple but the base number must not equal to zero.
    – M to N (m…n) means that you must specify the number form the start up to end. It is applicable for loop methods.


That completes our discussion about UML Class Diagram Discussion: Complete Guide with Examples Itsourcecoders.

I hope that this article helped you a lot. Not just by defining the UML Class Diagram but also on how to create it with the given examples and explanation.

Through the given UML Class Diagram Symbols, Examples and definition, you can start creating and design the UML Sequence diagram for your project. You can use all the information given in this article and apply it to your project development.


If you have any questions about the UML Class Diagram Discussion: Complete Guide with Examples, you can ask us through the contact page or leave your comment below.

Keep us updated and have a good day!

Related Article Below

Leave a Comment