In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what is the relationship in UML, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
There are mainly six kinds of relationships defined by UML: dependency, category, association, implementation, aggregation and combination. The understanding and use of these inter-class relationships is the key to mastering and applying UML, and these relationships often confuse beginners. Here is the description and class diagram description of the six main UML relationships. At first glance, they are clear. Here are some of these relationships:
Inherit
It refers to the ability of a class (called subclass, subinterface) to inherit the functions of another class (called parent class, parent interface) and to add its own new functions. Inheritance is the most common relationship between class and class or interface and interface. In Java, such relationships are clearly identified by the keyword extends, and there is generally no controversy at design time.
Realize
Refers to the function of a class class to implement interface interfaces (which can be multiple); implementation is the most common relationship between classes and interfaces; in Java, such relationships are clearly identified by the keyword implements, and there is generally no controversy at design time
Dependence
It can be understood simply that one class A uses another class B, and this usage relationship is accidental, temporary, and very weak, but the change of class B will affect A; for example, if someone wants to cross the river and needs to borrow a boat, the relationship between people and ships is dependent; at the code level, class B is used as a parameter in a method method.
Association
It embodies a strong dependency at the semantic level between two classes or classes and interfaces, such as my friend and me; this relationship is stronger than dependence, there is no contingency of dependency, and the relationship is not temporary, it is generally long-term, and the relationship between the two sides is generally equal, and the relationship can be one-way or two-way. At the code level, the associated class B appears in the associated class An in the form of class attributes, or it may be that the associated class A references a global variable of type B
Polymerization
Aggregation is a special case of association, which embodies the relationship between the whole and the part and ownership, that is, the relationship between the whole and the part, that is, the has-a. At this time, the whole and the part can be separated, they can have their own life cycle, and some of them can belong to multiple whole objects or can be shared by multiple whole objects, such as the relationship between computers and CPU, the relationship between companies and employees, etc. At the code level, it is consistent with the association, and can only be distinguished at the semantic level.
Combination
Combination is also a special case of relevance, which embodies a contains-a relationship, which is stronger than aggregation, also known as strong aggregation; it also embodies the relationship between the whole and the part, but at this time the whole and the part are inseparable, and the end of the life cycle of the whole means the end of the life cycle of the part; for example, you and your brain. At the code level, it is consistent with the association, and can only be distinguished at the semantic level.
There is no doubt about the relationship between inheritance and implementation, which embodies a vertical relationship between class and class, or between class and interface. The other four relationships reflect the reference and horizontal relationship between class and class, or between class and interface, which is difficult to distinguish. There are many relationships between things that are difficult to prepare for positioning. As mentioned earlier, these relationships are semantic level, so we can not completely distinguish all kinds of relationships from the code level. But generally speaking, the strength of the latter relationships is in the following order: combination > aggregation > association > dependence.
The above is all the content of this article "what's the relationship in UML?" 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.