Design Patterns -UML Relationship Basics UML relationship basics

Relationships between classes

generalization

Classes are represented by generalization and implementation in inheritance. The inheritance relationship is IS-IS – A. The inheritance relationship between two objects is IS-IS – A. A bicycle is a car and a cat is an animal. The generalization relationship is represented by hollow arrows as shown in the figure below. A inherits from B

A is represented by A hollow arrow as inheriting from B generalization relation as inheriting abstract class.

An abstract class can inherit from a concrete class. An abstract class can be inherited by an entity class

Realize the relationship between

Implementation relationships are represented by hollow arrows. This refers to an abstract class in C++ (implemented through pure virtual functions), an interface in Java, and an implementation relationship.

That is, objects that cannot be defined directly are called abstract classes.

That is, A inherits from the abstract class B at the top

The aggregation relationship

A line with A hollow diamond arrow shows A converging on B, which consists of A. Aggregation relations represent the relationship between entity objects and represent the semantics of the whole composed of parts.

A department consists of multiple employees. Is the aggregation relation.

The difference from combinatorial relationships is not strong dependence. Even if the whole does not exist, the parts still exist. Departments disappear, people don’t disappear, they still exist.

Combination relationship

The combinatorial relationship is represented by a diamond arrow with a solid core. A consists of B, and B consists of A. Combinatorial relation emphasizes aggregation relation with strong dependence. If the whole does not exist, the part will not exist. If the company does not exist, then the department will not exist.

correlation

The relation is represented by a straight line, which describes the structural relation between objects of different classes. A static relationship. It is usually independent of the running state. Used to define natural, static structures between objects. Passenger and ticket belong to correlation relation, student and school belong to correlation relation. Association relationships do not emphasize direction by default. If direction is emphasized, then A knows B, but B doesn’t know A

Using member variables

dependencies

A dashed line with an arrow shows the dependency between the two. A depends on B and describes the relationship between one object and another object at run time. Dependencies are embodied in the constructor of the class and the parameters passed in to the method of the class. The arrow points to the invocation relationship. Dependencies let objects know and use each other’s methods and properties.

Sequence diagram

Show details of the interaction between objects, using sequence diagrams. Sequence diagrams have objects, lifelines, control focuses, and messages.

www.iming.info