UML Class Diagram Relationship Summary

Source: Internet
Author: User
Tags modifiers
Relationship between

The following example will show the relationships independently for a specific purpose. Although the syntax is correct, these examples can be further refined to include more semantics within their valid range.

Dependence (Dependency)

A "use" relationship between entities implies a change in the specification of an entity and may affect other instances that depend on it ( figure D). More specifically, it can be converted to any type of reference to a class or object that is not in the scope of an instance. This includes a local variable, a reference to an object obtained through a method call (as shown in the following example), or a reference to a static method of a class (without an instance of that class). You can also use dependencies to represent the relationship between packages and packages. Because the package contains classes, you can indicate the relationship between packages and packages based on the relationships between the classes in those packages.

Figure D


Association (Association)

A structured relationship between entities indicates that objects are interconnected. The arrows are optional and are used to specify navigation capabilities. If there are no arrows, the hint is a two-way navigation capability. In Java, an association ( Figure E) is converted to a variable of an instance scope, just like the code shown in the "Java" area of Figure E. Additional modifiers can be attached to an association. The multiplicity (multiplicity) modifiers imply a 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)

Aggregation ( figure F) is a form of association that represents a global/local relationship between two classes. Aggregation implies that the overall concept is at a higher level than the local one, and the association implies that two classes are conceptually at the same level. Aggregations are also converted to an instance scope variable in Java.

The difference between association and aggregation is purely conceptual and is strictly reflected in semantics. Aggregation also implies that there is no loop in the instance diagram. In other words, it can only be a one-way relationship.

Figure F



Synthesis (composition)

Synthesis ( fig. G) is a special form of aggregation, implying "local" within the "whole" life-cycle responsibility. Synthesis is also not shared. Therefore, while the part does not necessarily have to be destroyed with the destruction of the whole, the whole is either responsible for maintaining a partial survival state or for destroying it. Local cannot be shared with other whole. However, the whole can transfer ownership to another object, which then assumes the lifetime responsibility.

The relationship between employee and timecard may be more appropriate to be expressed as "compositing" rather than as "association."

Figure G

Generalization (generalization)

Generalization ( figure H) represents the relationship between a more generalized element and a more specific element. Generalization is a UML element that is used to model inheritance. In Java, this relationship is represented directly by the extends keyword.

Figure h


Implementation (Realization)

Instance ( figure I) A relationship specifies a contract between two entities. In other words, one entity defines a contract and the other entity guarantees the fulfilment of the contract. When modeling a Java application, the implementation relationship can be represented 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.