Diagram analysis such as UML (dependency, association, aggregation, composition, generalization, implementation)

Source: Internet
Author: User

In my study of design patterns, I used UML for modeling.

At first I was not too clear on the understanding of the various relations, on the internet also searched some information, now on the class diagram of these kinds of relationships: dependency, association, aggregation, composition, generalization, implementation of a description.


First of all, we need to know two points:

1. Order of their relationships: generalization = implementation > Composition > Aggregation > Association > Dependency

2, Association, aggregation, combination only with semantics, combined up and down Wencai can be judged out, and only give a piece of code let us judge is the association, aggregation, or combination of relations, it is impossible to judge.


generalization (generalization):

Generalization is one of the most coupling relationships between objects. It represents an inheritance relationship. For example, the son class inherits the Father class.

A UML class diagram is represented by a solid line with a triangle, and the child class points to the parent class.


implementation (realization)

Implementation is one of the most coupling relationships between other objects. It represents the relationship between an interface and an implementation class. For example: The Implementsclass class implements the interface class.

A UML class diagram is represented by a dashed line with a triangle, and the child class points to the parent class.

combination (composition):

A combination is the second-to-last relationship, which represents the relationship between the whole and the part. For example, the relationship between man and hand, when the person is not, the hands will be gone.

The UML class diagram uses a solid diamond + solid line + arrow diagram to indicate that the owner of the Diamond side refers to the ClassA, the solid line on the side of the owner CLASSB.


Aggregation (Aggregation):

Aggregation is the second-to-composite relationship, which represents the relationship that an object owns another object. For example: the relationship between a car and a tyre. But a car without a tyre can still exist.

The UML class diagram uses the Hollow Diamond + solid line + arrow diagram to indicate that the diamond side refers to the owner of the ClassA, the solid line on the side of the owner CLASSB.

Association (Association):

The association is the second-to-aggregate relationship. Association relationship is generally long-term, and the relationship between the two sides is generally equal, the association can be one-way, two-way. For example: I have a car, the relationship between me and the car is one-way association. The arrow points to the car.

The UML class diagram is connected using a straight arrow, and the arrow refers to the object being associated.


dependency (Dependency):

Dependency is a weaker relationship than the association relationship. There are occasional and temporary dependencies. For example: I can drive, people give me a car, I can drive. The relationship between the car and me is dependent.

The UML class diagram is represented by a dashed line with arrows, and arrows are used to point to the dependent class from the class.



The above drawing tools use PowerDesigner 16.

Remark :
Reprint Please specify source: http://blog.csdn.net/wsyw126/article/details/51352249
WSYW126

Diagram analysis such as UML (dependency, association, aggregation, composition, generalization, implementation)

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.