UML class diagram of design patterns

Source: Internet
Author: User

Labels: UML class diagram

This article is my learning notes, welcome to reprint, but please note the Source: http://blog.csdn.net/jesson20121020


Previously, the diagram drawn in the factory method mode was not strictly in line with the UML class diagram, so I took a look at the UML class diagram today. Most of the content below is taken from the "big talk Design Pattern ".


Basic diagram of UML

UML class diagram example

Class diagram:

For example, a rectangular box represents a class ). It is divided into three layers. The first layer displays the class name. If it is an abstract class, it is displayed in italic. The second layer is a class feature, usually a field and attribute. The third layer is a class operation, usually a method or action. Note that '+' indicates public, '-' indicates private, and '#' indicates protected.


Interface diagram:

An interface graph can be expressed in two ways. One way is to use a rectangle frame (left) Like a class graph. The difference between an interface graph and a class graph is that the top is displayed <interface>, the first line is the interface name, and the second line is the interface method. There is another method that represents an interface, also known as the lollipop notation (right). It is represented by a circle and the interface name is next to the circle. The interface method appears in the implementation class.

Inheritance relationship:

As shown above, the inheritance relationship is represented by a hollow triangle + solid line.

Interface relationship:

As shown above, the implementation interface is represented by a hollow triangle + dotted line.

Link:

Penguins are very special birds, but they will not fly. More importantly, they have a lot to do with the climate. We will not discuss why there are no penguins in the Arctic and why they need to travel every year. In short, penguins need to "know" about climate changes and climate patterns. Association can be used when one class "knows" another class ). The associations are represented by the solid arrow.

Aggregation relationship:

Geese are group animals. Each group belongs to a group of geese. One group can have multiple geese. Therefore, the aggregation relationship is met between them. Aggregation indicates a weak "ownership" relationship. It indicates that object A can contain object B, but object B is not part of object. The aggregation relationship is represented by a hollow diamond + solid arrow.

Merging relationship:

The compositing relationship is a strong "ownership" relationship, which reflects the strict relationship between the parts and the whole, and is the same as the overall life cycle. Here, birds and their wings form a synthetic relationship because they are partially related to the whole, and the life cycles of wings and birds are the same. The compositing relationship is represented by a solid diamond + solid arrow. In addition, you can also note that there is a number "1" and "2" at each end of the line, which is called the base number, indicating that the class at this end can have several instances. Obviously, A bird should have two wings. If there is a class that may have multiple instances, it will be represented by "N". In addition, the Association and aggregation relations can also have a base.

Dependency:

The major characteristics of animals, such as metabolism and reproduction. Animals need vitality, oxygen, water, and food. That is to say, animals depend on oxygen and water, and their dependencies are expressed by dotted arrows.



UML class diagram of design patterns

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.