Relationships between classes

  • Generalization and implementation
  • Rely on
  • Aggregation, composition, and association

Generalization and implementation

generalization

Generalization is used to describe inheritance in UML terminology. When a class represents a shared feature of multiple classes, the class is said to be a generalization. It is expressed as: hollow triangle + solid line

implementation

The implementation in UML is used to represent the interface realization in object-oriented programming, expressed as: hollow triangle + dotted line

dependencies

A dependency is the most common type of relationship in A program. It is usually expressed as A method of one class taking an object of another class as A parameter, rather than creating an object of another class within the method

correlation

Associations are usually represented by solid arrows as follows:

There are two types of associations:

  1. Aggregation: An aggregation is A special type of association that can be thought of as A HAS-A relationship. A term used to describe a relationship in which a class logically contains another class, but instances of the included class can live independently of the context of the first class. (Both classes are generic, except that logically one class has an instance of the other as its domain.)
  2. Composition: Composition differs from aggregation mainly in that the relationship between the two classes is closer, not only in logical inclusion, but also in the fact that the combined class cannot exist independently, and the dependent class does not exist when the main class does not exist. For example, the relationship between hand and finger, house and room

The aggregation

Hollow diamond + solid line

combination

Solid diamond + solid line