NOTE

Class Diagram

What a class diagram is, how classes/interfaces and common class relationships are represented, with PlantUML examples.

Software Architecture & EngineeringCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is It?

Describes the attributes and methods of Classes in a system, as well as the relationships between Classes.

2. Usage

2.1. Classes and Interfaces

  • means public
  • means private

2.2. Relationships Between Classes

2.2.1. Generalization and Realization

Symbol: triangle.

Generalization means extending a class. Solid line.

Realization means implementing an interface. Dashed line.

PlantUML 图表

2.2.2. Aggregation and Composition

Symbol: diamond.

They emphasize the relationship between the whole and the part.

Aggregation refers to strong dependency, depending on another class as an attribute. Filled diamond.

Composition refers to weak dependency, depending on another class as an attribute. Hollow diamond.

PlantUML 图表

2.2.3. Association and Dependency in UML

Symbol: arrow.

Association means using another class as an attribute. Solid line.

Dependency means using another class as a method parameter. Dashed line.

PlantUML 图表

3. Example

PlantUML 图表

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub