UML class diagram and uml class diagram

Source: Internet
Author: User

UML class diagram and uml class diagram

I. First of all, I declare that the learning of UML class diagrams refers to the example in "big talk Design Pattern" for personal learning and does not involve anything else.

2. paste the Big Bird's UML pattern examples for the dishes.

Iii. Description:

1. Class Diagram

The first layer displays the class name. If it is an abstract class, it is represented in italic.

The second layer is the class features, usually fields and attributes.

The third layer is class operations, usually methods and actions.

Note: '+' indicates public, '-' indicates private, and '#' indicates protected.

2. Interface Diagram

The first layer is the interface name.

The third layer is the interface method. If it is an abstract method, it is represented in italic.

3. another expression of the interface: lollipop notation.

For example, Donald Duck speaks Chinese.

4. Relationship between classes

(1) Inheritance

The inheritance relationship is represented by a hollow triangle + solid line.

Represents the relationship between is-a, which is the most coupling relationship between objects. Subclass inherits all details of the parent class.

Such as the relationship between animals, birds, ducks, and Donald Duck.

(2) Association

The Association is represented by the sharp arrow + solid line. When one class "knows" another class, it can be associated.

For example, penguins need to know about climate changes and climate patterns.

(3) Aggregation)

Aggregation is represented by hollow diamond + solid line. The diamond points from the local to the whole.

Aggregation indicates A weak "ownership" relationship. It indicates that object A can contain object B, but object B is not part of object.

Represents the relationship between has-a, which is an unstable inclusion relationship. It is stronger than general association. It has a relationship between the whole and the local, and can exist separately without the whole.

Such as the relationship between the company and its employees, the company includes employees, but if the company fails, employees can still change the company.

Another example is that the geese are group animals, and each geese belongs to one group. One group can have multiple geese.

(4) Composition)

The combination is represented by the solid diamond + solid line, and the diamond points from the local to the whole.

Combination represents a strong "ownership" relationship, reflecting a strict partial and overall relationship, and the same as the overall life cycle.

It indicates the contains-a relationship, which is a strong inclusion relationship. The composite class is responsible for the life cycle of the composite class. Is a stronger aggregation relationship.

For example, if the relationship between the company and the Department is absent, the Department cannot exist. The relationship between the problem and option in the questionnaire; the relationship between the order and the order option.

Another example is that birds and wings are in a composite relationship. They are the relationship between the whole and the part, and the life cycle of wings and birds is the same.

(5) dependency)

The dependency is represented by the dotted arrow, and the arrow points to the dependent class from the use class.

Dependency indicates the weakest association between objects. It is a temporary Association.

(6) Multiplicity)

Usually used in association, aggregation, and combination. Indicates how many associated objects exist. It is represented by a number. Asterisk (number.

For example, a bird has two wings.

5. Relationship between classes and interfaces

Implementation Interface

The interface implementation is represented by a hollow triangle + dotted line. For example, Danyan implemented the flying interface, and Donald Duck implemented the method of talking.

 

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.