Definition and representation of several types of diagrams in UML

Source: Internet
Author: User

We know that object-oriented features are encapsulation, inheritance, and polymorphism. To make these relationships clearer, we often use UML class diagrams to represent them. Common relationships are as follows:

1. Class: indicates the encapsulation of an object. For example,

The top grid represents the class name, and italic indicates that the class is an abstract class. The second grid indicates the characteristics of the class, which is commonly referred to as fields and attributes. The third grid indicates the class operation,

That is, methods and actions. The preceding "+" indicates public, "-" indicates private, and "#" indicates protected.

 

2. Interface: refers to a series of method declarations that are not implemented. The class implementing this interface is responsible for implementing this interface.

 The top one represents the interface name, and the second represents some methods defined by the interface.

 

3. inheritance: uses the existing class definition as the base class, which can add new data or functions, or use the features of the parent class, however, the parent class cannot be inherited selectively. The specific expression method is hollow triangle + solid line.

Of course, in Java, to implement a multi-Inheritance mechanism similar to C ++, there is also an implementation (implements) interface class diagram. The specific representation method is hollow triangle + dotted line or lollipop notation.

4. Association: When a class needs to "know" the other class, it can be expressed by association and expressed by the real-line arrow.

 

5. aggregation: a weak "ownership" relationship, which is equivalent to inclusion, but not a part of it, so that it can be distinguished from synthesis and expressed using hollow diamond + solid arrow.

 

6. composition: it is also called a combination. It is a kind of strong "ownership relationship". It reflects a local and overall relationship, and its lifecycle is the same as that of the whole, use solid diamond + solid arrow. The numbers in the two segments of the link represent the base number, indicating that a class can have several instances and a person has a head. Therefore, they are represented.

 

7. Dependency: for example, if a human wants to drink water or eat, the dependency is represented by a dotted arrow.

 

 

Note: Because my Visio functions are limited, no images in sections 4 and 5 can be drawn, and all of them are from the Internet. In case of any problems, no legal liability shall be incurred.

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.