(UML summary of one) four relationships

Source: Internet
Author: User

UML Unified Modeling Language is a visual modeling language used to design software blueprints. Supports the analysis, design, implementation and delivery of object-oriented systems, and can be used for system understanding, design, browsing, maintenance and information control. UML is composed of basic building blocks, rules and public mechanisms therein.


The basic building blocks of UML include things, relationships, and graphs. Things are some basic graphical identifiers that make up model diagrams, and identify some basic concepts of object-oriented. Relationships are the relationships between basic diagram symbols. A diagram is an abstract description of a system from a specific perspective.

The most frustrating thing is four basic relationships: relevance, dependency, generalization, implementation. , associations also have special cases: aggregations and combinations.



first, let's start with a theoretical understanding of each relationship:

Correlation : We can refer to association relationships as " know ", which describes the structural relationships between two or more classes, i.e., a static relationship. Represent a strong dependency between two classes or the semantic level of a class and interface. Can be unidirectional, bidirectional, at the level of the code.


aggregation : is a "hasa " relationship, which represents the whole and part. (Hollow Diamond) The whole and the parts can exist independently of each other and have their own life cycle. such as automobiles and engines.


Combination : is a "contains a " relationship, which represents a subordinate. (solid diamond) is the whole existence, the part exists, if the whole is gone, the part no longer exists, the same life cycle. is stronger than the aggregation relationship.


Dependency : We can make a dependency a "use", which means that one class relies on another class's properties or methods, and two classes. is a temporary, cyclical "weak" relationship. As software health changes, dependencies can disappear. The arrow points to the relying party.

generalization : The generalization relationship is what we often call an object-oriented inheritance, namely "iskind of". Is that the definition of the parent class is valid for subclasses, and subclasses can have no parent class. The arrows refer to the parent class by subclasses.



implementation : is a semantic relationship between the classes, in which a class element describes a contract that guarantees the implementation of another class element. Typically, a class implements an interface. The arrow points to the interface.


Second, the relationship between the comparison:

Associations and Dependencies

Through the above introduction we can know that dependence is the most basic, the weakest relationship, association is a strong dependency relationship. The relationship between the two sides is equal, there is no contingency and temporary dependency relationship. Association relationships are generally long-term.


Composition and aggregation

Both the composition and the aggregation are related to each other, both in the description of the relationship between the whole and the part. The biggest difference is that the whole and part of the aggregation relationship can be independent of each other, and they have their own life cycle. The whole and the part of a combinatorial relationship are subordinate relations, indivisible, and the life cycle is the same.



Associations and Aggregations

Although the aggregation relationship is a branch of an association, it is still a matter of distinction. The two classes in the association relationship are equal, such as me and my friends. The two classes in the aggregation relationship are not one level, such as cars and engines. Cars and engines can exist independently of each other, and they are not a level.


Three, comprehensive analysis

By comparing the above, we get the degree of strength: Combination > Aggregation > Association > dependency. Dependency is the most basic and weakest relationship, and if the association relationship between two classes can be used to represent a library, do not use dependencies. The inheritance relationship between the two classes is generalized, if the interface and the class are implemented in relation to each other.

    

Iv. Summary

Through the comparison above, we can understand each relationship more clearly. This also reflects the importance of comparative learning, we do not put new knowledge into their own brain, but to take out the old, or to compare the two, so as to better understand. Understanding the relationships in UML, then start my drawing tour ~~~~~~



(UML summary of one) four relationships

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.