Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference and relationship between UML association and other relationships in UML class diagram relationship

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "UML class diagram relationship in the UML association and other relations have what differences and connections", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the differences and connections between the UML association and other relationships in the UML class diagram relationship?"

Connections and differences of UML association, dependency, aggregation, and composition in UML class diagram relationships

In the class diagram, in addition to describing the names, attributes, and operations of individual classes, we also need to describe the relationships between classes, because no classes exist alone, and they usually need to collaborate with other classes to create greater semantics than working alone. In the UML class diagram, the relationship is represented by the connection between the class boxes, and the different modifiers on the connection and at the end of the connection represent different relationships.

In the UML class diagram relationship, the relationship of association, dependence, aggregation and composition is very close, and it is not easy to distinguish. This paper attempts to use popular language to explain the difference between these four relationships.

Association

In the UML class diagram relationship, association is the occurrence relationship. A class An is associated with class B, indicating that the fields (or attributes) in class A contain a link to an instance of class B (a pointer in C++). Class B can also associate class A with class A. they are equivalent and there is no distinction between primary and secondary.

Dependence:

Class A depends on class B, indicating that class B is used in class A, which is "used" to a lesser extent than correlation. For example, class B is used in local variables (variables and function parameters in a function), or class A uses a static function of class B.

Gather:

Aggregation is also a kind of association in the UML class diagram relationship, but for the association, both sides of the association are equal, there is no primary and secondary distinction, in the aggregation, there is primary and secondary, and there can only be one "primary" party. As far as the computer is concerned, the "computer" is an object, and he is the "master". While "hard disk", "motherboard", "monitor" and so on are the "secondary" party, "hard disk", "motherboard" and "display" are gathered into "computer". They are just the relationship of aggregation, and the motherboard is finished, and it does not affect the display, so we can understand that the object in the aggregation is a whole and independent.

Composition:

The composition of the UML class diagram relationship is a special aggregation (which is also related, of course). Take the table, for example, the table is composed of the table and the table legs, but the table without the table or the table legs cannot be called a table. That is to say, for the parts that make up the object, they have an organic whole, an inseparable whole. The table object (body object) is responsible for the life cycle of the desktop and table legs ("secondary" object, primary and secondary). In C++ language, a table object contains object instances of a table object and a table leg object. This is not a pointer, but it is a pointer in aggregation, which is the difference between aggregation and composition.

These are all the contents of this article entitled "what are the differences and connections between UML associations and other relationships in UML class diagram relationships?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report