Six Types of UML class diagrams

Source: Internet
Author: User

Inheritance: Solid line of the hollow triangle arrow. The Child class points to the parent class. Common keywords in code are extends (Java ).

Implementation: Dotted line of the hollow triangle arrow to implement class pointing interface. The implements keyword (Java) is usually used in the code ).

Association: Generally, the instance of another class B needs to be referenced in Class A as a member variable, indicating that Class A needs to "know" Class B. The solid arrow. Class A points to Class B.

DependencyGenerally, a method in Class A requires an instance of Class B as its parameter, and Class A itself does not need to reference an instance of Class B as its member variable. The dotted arrow points to Class B.

 

Aggregation: Generally, Class A needs to include an instance or a set of instances of another class B, indicating a weak "ownership" relationship, that is, Class A contains Class B, but Class B is not a part of Class A, but an independent class. The solid arrow with a hollow diamond tail points to Class B.

Synthesis: Class B is usually instantiated in its constructor while Class A is instantiated, so that Class B is a part of Class A and represents a strong "ownership" relationship, that is, Class B is a part of Class A, which has a strict "Whole-part" relationship. The implementation arrow at the end is solid diamond, and Class A points to Class B.

1. Overview

In the UML design Class, Class relationships are divided into five types: generalization (generalization), dependency (dependency), Association (association), aggregation (aggregation), and composition!

2. generalization (generalization)

Generalization (generalization) represents the inheritance or implementation relationship (is ). The specific form is the inheritance relationship between classes, the inheritance relationship between interfaces, and the Implementation relationship between classes and interfaces.

3. Dependency (dependency)

It is represented by the parameter (Use A) in the function ). Is the connection between classes, indicating that one class depends on the definition of another class. Changes to one class will affect the other class. For example, if a depends on B, B is embodied as a local variable, a method parameter, or a static method call.

4. Association)

It is represented as a variable (Has ). A join between a class and a class. It allows a class to know the attributes and methods of another class. For example, if a depends on B, B is the global variable of. Associations are bidirectional and unidirectional. Two-way Association: both classes know the public attributes and operations of the other class. One-way Association: only one class knows the public attributes and operations of the other class. Most associations should be one-way, which makes it easier to establish and maintain one-way relationships and helps you find classes that can be taken.

5. Aggregation (aggregation)

A strong association is a type of association. The aggregation relationship is the relationship between the whole and the individual. The two classes of the common association relationship are at the same level, while the two classes of the aggregation relationship are at different levels. One is the whole, and the other is the part. At the same time, it is a weak "ownership" relationship. Object A can contain object B, but object B is not an integral part of object. Specifically, if A is aggregated by B, it means that a contains a Global Object with B, but B can be created at the time when a is created.

6. Composition (combination)

A type of association relationship, which is stronger than an aggregation relationship. It requires that the object representing the whole in a common aggregation relationship be responsible for representing the lifecycle of some objects. Composition (composite relationship) is a strong "ownership" relationship, reflecting the strict relationship between the parts and the whole, and consistent with the overall life cycle. If a is composed of B, it means that a contains a Global Object of B, and B is created at the moment when a is created.

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.