Classes
In UML visualization, classes are Unified Modeling Language (UML) diagram elements that represent abstractions of an object or set of objects that share a common structure and behavior.
A class identifies the attributes, operations, relationships, and semantics that instances of the class possess. Every object that instantiates a class usually provides its own attribute values. Attributes are also called variables, member variables, properties, and fields, but are usually implemented as variables.
A class is displayed in a diagram as a rectangle with three compartments.
![]()
You can use additional compartments to display other details such as constraints or signals that instances of the class can receive.
The classes in an application usually appear in class diagrams. Classes or instances of classes (objects or classifier roles) also appear frequently in other types of diagrams, including sequence diagrams. You can add classes to diagrams to represent the following items:
- Workers and artifacts of a business
- Components or building blocks of a software system, such as Java classes and database tables for databases
Example
An e-commerce application might include a Cart class. The class defines an itemList attribute, and an addItem operation that belong to all objects of type Cart. At run time, multiple instances of the Cart class might be created, each possessing the attributes and operations that the class defines. The values of the attributes for each instance will differ if, for example, one class object calls the addItem operation to add videos to its itemList attribute, while another instance uses the same operation to add books.
Parent topic
About UML class diagrams
Related concepts
Class diagrams
Class shapes
Classifiers
Relationships
Attributes
Operations
Adornments for unresolved references
Multiplicity
Visibility