) UML static view relationship and association

Source: Internet
Author: User

· Relationship

 

The relationships between class elements include associations, generalization, streams, and various forms of dependencies, including implementation relationships and usage relationships (see Table 4-2 ).

The Association describes the semantic connections between individual objects of a given class. Associations provide connections between objects of different classes that can interact with each other. The rest of the relationships involve descriptions of the class meta itself, rather than their instances.

The generalized relationship connects the parent class Meta (superclass) with a more specific descendant class Meta (subclass. Generalization is conducive to the description of the class element. Redundant declarations are not required. Each declaration must contain a description inherited from its parent class. The Inheritance mechanism constructs a complete class meta description using the additional description of the generalization relationship. Generalization and inheritance allow different class meta-shared attributes, operations, and their relationships, without repeated descriptions.

The implementation relationship is explained and linked with the implementation. Interfaces are descriptions of behaviors rather than implementations, while classes contain the structure of implementations. One or more classes can implement one interface, and each class implements operations in the interface separately.

Stream links two versions of an object in a continuous manner. It indicates the conversion of the value, status, and position of an object. The stream relationship can connect the class meta-roles in one interaction. Stream types include changing to (different versions of the same object) and copying (creating a new object from an existing object.

Dependencies associate behavior and implementation with classes that affect other classes. In addition to implementation relationships, there are also several dependency relationships, including trace relationships (a loose connection between elements in different models) and refined relationships (A ing between two different levels of meaning), use relationship (another element is required in the model), binding relationship (specify a value for the template parameter ). Dependencies are often used to indicate the relationship between specific implementations, as shown in figureCodeLayer implementation relationship. Dependency is useful when summarizing the organizational unit of a model, such as a package. It shows the architecture of the system. For example, compile constraints can be expressed by dependencies.

Table 4-2 link types

Link

Function

Representation

Association

Description of the connection between class instances

Dependency

Relationship between two Model Elements

Stream

Relationship between two forms of an object in a successive period

Generalization

A more general description and a more specific relationship between types, applicable to inheritance

Implementation

Description and relationship between implementations

Use

When an element requires other elements to provide appropriate functions

· Association

 

Association describes the discrete connections between objects or instances in the system. An association is a class element that contains two or more ordered tables and is connected when replication is allowed. The most common Association is a binary association between class elements. One of the associated instances is the chain. Each chain consists of a group of objects (an ordered list), and each object comes from the corresponding class. A binary chain contains a pair of objects.

Associate Information with the relationship between objects in the system. During system execution, the connections between objects are established and destroyed. Association is the "adhesive" used in the entire system. Without it, there are only isolated classes that cannot work together.

If the same class appears more than once in association, a single object can be associated with itself. If the same class appears twice in an association, the two instances do not have to be the same object. This is usually the case.

Any connection point associated with a class is called the Association end, and many information related to the class is attached to its endpoint. The Correlated end has features such as name (role name) and visibility, while the most important feature is the diversity. Duplication is very important for Binary associations because it is complicated to define N-yuan associations.

Binary join is represented by a line connecting two classes. As shown in Figure 4-2, there are correlated role names on the line, and the multiple roles are added to each endpoint.


Figure 4-2 Association notation

If an association is both a class and an association class, that is, it can have its own attributes (such as Figure 4-3 ). If an associated attribute is unique in a group of related objects, it is a qualifier (4-4 ). A qualifier is used to identify unique object values from a group of related objects in an association. The qualifier is very important for modeling names and identity code. It is also an index for designing models.


Figure 4-3 Association class


Figure 4-4 limit Association

In the analysis phase, Association indicates the logical relationship between objects. There is no need to specify directions or care about how to implement them. Avoid unnecessary associations as much as possible because they do not add any logical information. In the design phase, Association is used to describe the design decision on the data structure and the separation of duties between classes. At this time, the direction of association is very important. In order to improve the object access efficiency and locate specific class information, some necessary redundant associations can also be introduced. However, in this modeling phase, the association should not be equal to the pointer in the C ++ language. Navigative associations in the design phase represent State information useful to a class, and they can be mappedProgramDesign Language. Association can be implemented using a pointer, nested class, or even a completely independent table object. Other design attributes include visibility and chain modifyability. Figure 4-5 shows some associated design features.


Figure 4-5 associated Design Features

1. Aggregation and composition

Clustering indicates the correlation between the part and the overall relationship. It is represented by a line segment with an empty diamond at the endpoint, And the empty diamond is connected to the clustering class. Composition is a stronger form of association, with the unique responsibilities of the overall management part. It is represented by an solid diamond object attached to the composition end. Each class that represents a part has a separate association with the class that represents the whole, but for convenience, the connections are combined, and the entire group is now associated with a tree. Figure 4-6 shows the clustering Association and composition Association.


Figure 4-6 aggregation and composition

2. Chain

A link is an associated instance. A chain is an ordered table of the objects involved. Each object must be an instance of the corresponding class in the association or an instance of such descendants. Links in the system constitute part of the system status. Links do not exist independently of objects. They get their own identities from the objects associated with them (in database terms, the object list is the key of the chain ). In terms of concept, associations are significantly different from related classes. In practice, Guan Unicom often uses pointers to related classes, but they can be implemented as the inclusion object separated by the connected classes.

3. Bidirectional

The associated different ends are easily identified, even if they are of the same type. This only means that different objects in the same class can be associated with each other. Because the two ends are differentiated, the Association is asymmetric (except for some examples), and the two endpoints cannot exchange with each other. In general, this is a consensus: just as the subject and object in a verb phrase cannot be exchanged. Associations are sometimes considered bidirectional, which means logical relationships work in both directions. This point of view is often misunderstood, and even involves some methodologists. This does not mean that each class "understands" other classes, or that classes and classes can access each other in the implementation. This only means that any logical relationship has its inverse nature, regardless of the reverse nature, it is not easy to calculate. If the association only crosses one direction but not the other, the Association is considered to be navigation.

Why use the basic model insteadProgramming LanguageAre commonly used pointers to indicate associations? The reason is that the model tries to explain the purpose of the system. If the relationship between the two classes is represented by a pair of pointers in the model, the two pointers are still related. The association method indicates that the relationship is meaningful in both directions, regardless of how they are implemented. It is easy to convert the association into a pair of pointers for implementation, but it is hard to show that the two pointers are inverse to each other unless they are part of the model.

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.