Skip to main content

Section 13.2 Unified Modeling Language

Unified Modeling Language (UML) is a graphical language used to model the structure and behavior of object-oriented systems. It is widely employed in industry to design, develop, and document complex software systems.
Unified Modeling Language (UML) is a graphical language used to model the structure and behavior of object-oriented systems. It is widely employed in industry to design, develop, and document complex software systems. In this context, we will focus on UML class diagrams, which represent the internal structure of classes, including their attributes, methods, and visibility. UML class diagrams also capture relationships between classes—such as associations, dependencies, and inheritance—within object-oriented design.
This section outlines key elements of UML that are essential for understanding and representing classes at a foundational level. It does not aim to cover all aspects of UML but instead highlights the minimum features needed to effectively model a class using UML class diagrams.
This serves as the first step, and we will continue to build on this foundation as we introduce and explore object-oriented concepts and design principles. For a more in depth discussion refer to this article from IBM Developer on class diagrams

Subsection 13.2.1 Class Diagrams

A class diagram represents each class as a rectangle divided into three sections:
  • The class name (top section).
  • The fields—names and types of attributes (middle section).
  • The methods—names, return types, and parameters (bottom section).
This structure provides a clear visual representation of a class’s internal details.
To illustrate, consider a Person class and a Book class as examples. While the following Java class definition is intentionally simplified, it effectively demonstrates the core UML data representations.
For example, a Circle class and a Book class might be modeled like this.
Figure 13.2.1. This UML diagram illustrates a Person as a datatype
Figure 13.2.2. This UML diagram illustrates a Book as a datatype
This shows that a Person object has private fields named name and birthDate, along with public methods named getName, setName, and isBirthday. Similarly, a Book object has private fields named title and authors, and public methods named getTitle, getAuthors, and addAuthor.
In these examples the fields and methods are annotated to indicate their access level:
  • + (plus) for public - members declared as public can be accessed from anywhere within the program.
  • - (minus) for private - members declared as private can only be accessed within the same class.
  • # (hash) for protected - members declared as protected can be accessed within the same class and by its subclasses.
UML conventionally uses Algol-style naming, where:
  • Variables are written as name:type.
  • Methods are written as name(params:type), where each parameter is listed with its name and type.
In UML, metadata can be represented using stereotypes, which are enclosed in guillemets (<< >>). For example, a constructor method may be labeled with the «constructor» stereotype.
We will introduce concepts like static members (underlined) and abstract members (italicized) in later sections as we expand our understanding of UML and object-oriented design.
Watch the first 4 minutes of this video for a quick tutorial about creating class diagrams. The rest of the video dives into relationships between classes which we will cover later in the course. Feel free to watch it as a look forward!
You have attempted of activities on this page.