Analysis of the meaning of UML arrows and lines

Source: Internet
Author: User

When learning UML, you often encounter UML class diagrams. Here we will introduce the meaning of UML arrows and lines, I believe that you have a clearer understanding of the meanings of arrows and lines in UML through the introduction in this article.

AD:

This section describes the meanings of UML arrows and lines. The relationships in UML mainly include dependency, aggregation, synthesis, generalization, and implementation, next let's take a look at how these relationships are implemented using UML arrows and lines.

UML arrows and linesProgram

Link

The following examples show various relationships for a specific purpose. Although the syntax is correct, these examples can be further refined to include more semantics within their effective scope.

Dependency)

An "use" Relationship between entities implies that when the specification of an object changes, other instances dependent on it may be affected (Figure D ). More specifically, it can be converted to any type of reference to a class or object not in the instance scope. This includes a local variable that references an object obtained through method call (as shown in the following example ), or reference a static method of a class (there is no instance of that class at the same time ). You can also use "dependency" to indicate the relationship between packages. Because the package contains classes, you can express the relationship between packages and packages based on the relationships between classes in those packages.

Figure D

MB +? U Association)

A structured relationship between objects indicates that objects are connected to each other. The UML arrow is optional and is used to specify the navigation capability. Without arrows, it implies a two-way navigation capability. In Java, Association (Figure E) is converted to an instance-specific variable, as shown in Figure E's "Java" area.CodeThat way. You can append other modifiers to an association. The multiplicity modifier implies the relationship between instances. In the Demo code, the employee can have 0 or more timecard objects. However, each timecard only belongs to a single employee.

Figure E

Aggregation)

Aggregation (Fig F) is a form of association. The UML arrow represents the overall/local relationship between two classes. Aggregation implies that the whole is at a level higher than the local level, while association implies that two classes are at the same level in concept. Aggregation is also converted to an instance scope variable in Java. 7 mirrhk
Yc7lr # n8j0
The difference between Association and aggregation is purely conceptual and strictly reflected in semantics. Aggregation also implies that there is no loop in the instance diagram. In other words, it can only be a unidirectional link.

Figure F

Composition)

Merging (graph G) is a special form of aggregation. The UML arrow implies the lifetime responsibilities of "local" within "Overall. Synthesis is not shared. Therefore, although local data may not be destroyed as a whole, it is either responsible for local survival or destruction. It cannot be shared with other entities. However, ownership can be transferred to another object as a whole, and the latter will assume the responsibility for survival.

The relationship between employee and timecard may be more suitable for "merging", rather than "associating ".

Figure G

Generalization)

Generalization (Figure H) indicates the relationship between a more generalized element and a more specific element. Generalization is a UML element used to model inheritance. In Java, the extends keyword is used to directly represent this relationship.

Figure H

Implementation)

The instance (figure I) link UML arrow specifies a contract between two entities. In other words, one entity defines a contract, and the other entity guarantees the performance of the contract. When modeling a Java application, the implementation relationship can be expressed directly by the implements keyword.

Figure I

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.