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

Example Analysis of UML Class Diagram relationship

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the example analysis of UML class diagram relationship, which is very detailed and has certain reference value. Friends who are interested must finish it!

UML class diagram relationship

1. Association

The representation is a straight line with arrowheads.

two。 Aggregation / combination

When there is a whole-part relationship between classes, we can use composition or aggregation. The combinatorial representation method in UML class diagram relation is a straight line with arrowhead + solid diamond, and the aggregate representation is a straight line with arrowhead + hollow diamond.

Aggregation and combination represent the relationship between the whole and the part, but in aggregation one class can exist independently from another. (independent existence means that the existence of this class is meaningful in the problem domain of an application. ). The combination is just the opposite.

At the same time, it should be noted that this independence is not absolute, it depends on the specific context and problem areas. For example, in the field of concern for cars, tires and cars are combined, because it is meaningless without cars. But in the tire shop business, even if the tire leaves the car, it still makes sense, which can be used to aggregate.

3. Dependence

Dependency in UML class diagram relationship means that one class A may use some methods of another class B, that is, in order to complete all the functions in class A, there must be methods in class B. Generally speaking, two-way dependence is not allowed. Represents a dashed line with arrowheads for the method.

What's the difference between dependency and aggregation\ combination, association, etc.?

Relevance is a relationship between classes, such as teachers teaching students, kettles filled with water, and so on. This relationship is very obvious and can be obtained directly through analysis in the problem area.

Dependency is a kind of weak association, as long as one class uses another class, but the relationship with another class is not too obvious (it can be said that "uses" that class), we can regard this relationship as dependency, dependency can also be said to be an accidental relationship, rather than an inevitable relationship, that is, "I accidentally used it in a method, but in reality I don't have much to do with it." For example, I have nothing to do with the hammer, but once I used it when I wanted to hammer in a nail, which is a kind of dependence, relying on the hammer to do the thing of hammering.

Combination is a whole-part relationship, which is obvious in the problem domain and can be obtained by direct analysis. For example, the tire is part of the car, the leaves are part of the tree, and there is a very obvious whole-part relationship.

4. Generalization (inheritance)

The generalization in the UML class diagram relationship, the relationship between classes is easy to understand, that is, there is a generalization relationship, and the representation method is a straight line + hollow triangle.

5. Realize

This is the relationship between classes and interfaces, which is easy to understand. The representation method is virtual line + hollow triangle.

The above is all the contents of the article "sample Analysis of UML Class Diagram relationships". Thank you for reading! Hope to share the content to help you, more related 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