Fundamentals 10 min read

UML Relationship Types: Dependency, Association, Aggregation, Composition, Generalization, and Realization

This article explains UML's six core relationship types—Dependency, Association, Aggregation, Composition, Generalization, and Realization—detailing their semantics, visual notations, and how they are expressed in Java or C++ code.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
UML Relationship Types: Dependency, Association, Aggregation, Composition, Generalization, and Realization

UML defines several ways to describe relationships between objects and classes, including Dependency, Association, Aggregation, Composition, Generalization, and Realization.

Dependency is a one‑way relationship where a change in element A may affect element B; it is shown with a dashed arrow. Types of dependency such as usage, call, parameter, send, instantiate, trace, refine, derive, access, import, friend, and bind are described with UML stereotypes.

Method‑parameter example of a dependency:

public class Person {
    void buy(Car car) {
        // ...
    }
}

Association represents a structural link between classes, typically implemented via member variables; it can be uni‑ or bi‑directional and is shown with a solid line.

Association example in Java/C++:

public class 徒弟 {
    // ...
}

public class 唐僧 {
    protected: list<徒弟> tdlist;
}

Aggregation is a special form of association indicating a whole‑part relationship, depicted with a hollow diamond on the whole side.

Aggregation example:

public class 引擎 {
    // ...
}
public class 轮胎 {
    // ...
}
public class 汽车 {
    protected: 引擎 engine;
    protected: 轮胎 tyre[4];
}

Composition is a stronger whole‑part relationship where the part’s lifecycle is bound to the whole, shown with a filled diamond.

Composition example:

class 肢 {
    // ...
}
class 人 {
    protected: 肢 limb[4];
}

Generalization models inheritance (a “is‑a” relationship) and is drawn with a solid line and a hollow triangle arrow pointing to the general element.

Realization models the implementation of an interface, using a dashed line with a hollow triangle arrow.

These UML relationships help designers capture semantic connections between software elements, while the code snippets illustrate how they manifest in typical Java or C++ implementations.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

software designUMLdependencyaggregationcompositionObject Relationships
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.