Description of the relationship in UML (2)

Source: Internet
Author: User

The relationships in UML are hard to remember. Here I will summarize and briefly introduce the commonly used relationships in UML.

Note: The sample image is drawn using EA 7.5.

Five basic relationships of UML (class diagram as an example)

Association

Link elements and instances, and connect two model elements with no direction to the real line.

The two ends of the association can be marked by both sidesRoleAndMultiple

Real things do not exist in isolation. There is a certain relationship between objects, such as teachers and students.Association.

 

Create role

Role:

Assume the role "target" on behalf of class3, such as "person", "appreciation", and "performance ".

People are elements, appreciation is relationship, performances are target elements, people are "audience", and performances are "actors"

Visibility:

There is a "+" in front of the "destination" in the following example. It indicates that this class contains accessible features or methods, "-" indicates that the class contains implicit features and methods.Uml2.0 no longer uses visibility. The default value is +.

Build multiple (level ):

Link creation name

Navigation 

Another feature of a link is "navigation". The navigation feature is that an arrow appears in the implementation section of the link, representing one-way visibility or the use of pointed objects (including members, or call a method or something). If two-way navigation is required, the arrow is omitted, because by default, the relationship without arrows represents two-way navigation, you can define the navigation name for the link to better describe the meaning of the navigation, for example, people-use-> cars, but cars cannot use people.

 

Dependency

Dependency describes the dependency between an element and another element.Dotted arrowPoint to the target model, representing the source objectDependent onTarget objectExist.

That is to say, the source references the target

Create a dependency

Drag a link from the toolbar.Change typeTo change the type,ReverseIn the left-side Navigation Pane. You can also add dependencies.Multiple, name.

 

General relationship (inheritance relationship)

Generalization indicates that one element is a special case of another element ., The following figure shows the solid line of a triangle. The Source Element (special) is a special case of the target element (general ).

Multiple identifiers cannot be created for generalized relationships.

You can drag a new one from the toolbar.

 

Implementation relationship

An Implementation relationship describes an element that implements another element. For example, a class defines an interface and is represented by a dotted line triangle. The following shows that the class implements the interface.

Create an implementation

We can see that he hasConstructor realize cannot be removed,HeNoAddition and multiplexing

 

Aggregation relationship

The aggregate relationship describes the relationship between the part and the whole, that is, an incremental model element can be composed of several model elements that represent the part.

ExampleIn a single aggregation, the desktop (overall) is composed of a host (partial) + A display (partial), and only these two parts are available. For example, if you want a desktop, the host and a display must exist, you only need these two parts.

Aggregation means that a complex object can be combined by multiple simple objects.

Program understanding aggregation:

Class

{

B [] B;

}

That is, the definition of B will be used in the program;

You can useDependency.

As shown in the preceding figure, C4 is composed of C5 and C6. Right-click the aggregation relationship and a set aggregation to composite option is displayed.AggregationAndCombination (composition)Switch between the two relationships.

 

 

Composite (composition) relationship

Composite (combination) relationships are more coupled. Both composite and aggregation indicate that the whole is composed of parts. The difference is that the whole part must exist, for example, in the image below, if no database is available, no tables and stored procedures are available.

 

Program understanding aggregation:

Class

{

B;

A

{

B = 1;

}

}

That is, B will act as a member of;

 

A composite relationship can contain multiple tables, which indicates that one database can correspond to one or more tables, and one Database can correspond to zero or more stored procedures, here, databases are required to have at least one database, and there is a one-to-many relationship.

 

Relationship in the use case diagram

 

Inclusion relationship

The inclusion relationship indicates that some public parts are extracted and used as a new use case.

Note: The inclusion relationship indicates that this link use case will be executed, that is, this regular meeting is always required for execution.

Add include to the dotted arrowConstructor

This figure shows that both uc1 and UC2 will execute the uc3 definition requirements.

 

Extended relationships

An extended relationship is a dependency that specifies a use case to enhance the functionality of another use case.

Key point: the extension relationship can be directly understood as conditional execution, rather than being executed, but executed only as needed.

Note: his arrow is in the opposite direction.

 

What isConstructor

Constructor is an extension mechanism that isolates the semantics of defined elements in UML. Prevent UML from being too complex.

A constructor uses a word to express a certain meaning. There are too many constructor types in a link or element, and it generally does not need to be viewed or memorized. It can be used to understand its meaning.

For standard constructor tables, refer to page 226 of object-oriented design and analysis.

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.