Six major relationships in UML

Source: Internet
Author: User

There are six main types of relationships defined by UML: dependency, inheritance, association, implementation, aggregation, and composition. The understanding and use of these inter-class relationships is the key to mastering and applying UML, and that is how these relationships tend to confuse beginners. Here is a description of the six main UML relationships and a description of the class diagram, which is clearly understood below, and describes each of these relationships as follows:

Inherited

Refers to the ability of a class (called a subclass, sub-interface) to inherit the functionality of another class (called a parent, parent interface) and to augment its own new functionality, which is the most common relationship between classes and classes or interfaces and interfaces, and is generally not controversial at design time;

Realize

Refers to a class class implementation of the interface interface (can be multiple) function, the implementation is the most common relationship between the class and interface, at design time is generally not controversial;

Depend on

It can be simply understood that a class A is used to another class B, and that the use of the relationship is contingency, temporary, very weak, but the B-class changes will affect A; For example, someone needs to cross the river, need to borrow a boat, when the relationship between man and ship is dependent;

Represented at the code level; Class B is used as a parameter by Class A in a method;

Association

He embodies a strong dependency between the two classes, or the semantic level of the class and interface, such as me and my friends; this relationship is more than dependence, the contingency of no dependency, the relationship is not temporary, generally long-term, and the relationship between the two sides is generally equal, the association can be one-way, two-way;

At the code level, the associated class B appears as a class attribute in the association Class A, or the association Class A refers to a global variable of the type being associated with Class B;

Polymerization

Aggregation is a special case of association relationship, he embodies the whole and part, the relationship of ownership, that is, the relationship between the whole and the part is has-a, they can have their own life cycle, some can belong to multiple whole objects, can also be shared for multiple whole objects, such as computer and CPU, The relationship between company and employee, etc.;

Performance at the code level, and the association is consistent, can only be differentiated from the semantic level;

Combination

The combination is also a special case of the relationship, he embodies a contains-a relationship, which is stronger than aggregation, also known as strong aggregation, he also embodies the relationship between the whole and part, but at this time the whole and part is not divided, the whole life cycle end also means that part of the life cycle end , like you and your brain;

Performance at the code level, and the association is consistent, can only be differentiated from the semantic level;

There is little doubt about inheritance and realization of these two relationships, they embody a kind of class and class, or the vertical relationship between class and interface;

The other four relations are the class and class, or the class and interface between the reference, the horizontal relationship, is more difficult to distinguish between a lot of things to prepare for positioning is difficult, mentioned earlier, these relationships are semantic level, so from the code level and can not completely distinguish between the various relations;

However, in general, the following relationships are manifested by the degree of strength: Combination > Aggregation > Association > dependency.

Six relationships in UML (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.