UML Class Diagram Explanation

This section explains the key concepts of Class Diagrams and UML as described below.

Class Diagram Symbols

The main symbols shown on class diagrams are:

Diagram: Class Diagram Symbols

Refer to the PDF for the visual representation of class diagram symbols.

Classes

A class represents a concept and encapsulates state (attributes) and behavior (operations). Each attribute has a type, and each operation has a signature. The class name is the only mandatory information.

Diagram: Class Example

Refer to the PDF for the visual representation of a class with attributes and operations.

Associations and Multiplicity

Associations show how two classes are related to each other. Multiplicity symbols indicate how many instances of one class are related to another. For example:

Diagram: Association Example

Refer to the PDF for the visual representation of associations and multiplicity.

Aggregation and Composition

Aggregation is a special type of association that models a whole-part relationship. For example, a college is made up of students, but students can exist independently of the college.
Composition is a stronger form of aggregation where the parts cannot exist without the whole. For example, a house is composed of rooms, and if the house is destroyed, the rooms are also destroyed.

Diagram: Aggregation and Composition

Refer to the PDF for the visual representation of aggregation and composition.

Generalization and Inheritance

Generalization is used to create inheritance hierarchies. Subclasses inherit attributes and operations from their superclass. For example, a Button class can have subclasses like ZoneButton and CancelButton.

Diagram: Generalization and Inheritance

Refer to the PDF for the visual representation of generalization and inheritance.

Example: Company Structure

A company consists of departments, which are located in one or more offices. Each department has a manager recruited from the set of employees. This can be modeled using a class diagram with classes like Company, Department, Office, and Employee.

Diagram: Company Structure

Refer to the PDF for the visual representation of the company structure class diagram.