Detailed description of the relationship between UML class diagrams and Classes

Source: Internet
Author: User

Http://www.uml.org.cn/oobject/201104212.asp

 

When drawing a class chart, clarifying the relationship between classes is the focus. Class relationships include generalization, implementation, and dependency.
(Dependency) and Association ). Association is divided into general association and aggregation.
(Composition ). The following describes the relationships with instances.

Basic Concepts

Class digraphs: class diagrams are the most common and important diagrams in object-oriented system modeling and are the basis for defining other diagrams. A class chart is a static model used to display the classes and interfaces in the system and their static structures and relationships.

Three basic components of a class chart: Class Name, attribute, and method.

Generalization: indicates the relationship between is-A, which is the most coupling relationship between objects. Subclass inherits all details of the parent class. Directly use the inheritance expression in the language. Use a solid line with a triangular arrow in the class diagram, and the arrow points from the subclass to the parent class.

Implementation: In the class diagram, it is the relationship between interfaces and implementations. There is nothing to talk about. In the class diagram, use a dotted line with a triangular arrow to indicate that the arrow points from the implementation class to the interface.

Dependency: the weakest association between objects. It is a temporary Association. In the code
Call relationships between partial variables, function parameters, and returned values for other objects. A class call is dependent on some methods in the class to fulfill some of the class's responsibilities. Use a dotted line with arrows in the class chart, and an arrow
From the usage class to the dependent class.

Association: A Reference relationship between objects, such as the relationship between the customer class and the order class. This relationship is usually expressed by class attributes. Association is divided into general association, aggregation Association, and combination Association. The last two types are analyzed later. In a class chart, use a solid line with an arrow to indicate that the arrow points from the class to the associated class. It can be unidirectional or bidirectional.

Aggregation ):
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. In a class chart, a hollow diamond is used to indicate that the diamond points from the local to the whole.

Composition ):
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. Some cannot be separated from the whole. For example, company and department Customs
Department, no company, no department, the relationship between the questions and options in the questionnaire, and the relationship between orders and order options. In the class chart, the solid diamond is used to indicate that the diamond points from the local to the whole.

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 cutover notification can be associated with 0 to N fault tickets.

Differences between aggregation and combination

These two are hard to understand. Let's focus on them. The difference between aggregation and combination is that the aggregation relationship is the "has-a" link, and the combination relationship is the "contains-a" link; the aggregation relationship indicates the whole and part
The relationship is relatively weak, but the combination is relatively strong; the Objects representing some things in the aggregation relationship are irrelevant to the lifetime of the objects representing the aggregation things, once an aggregate object is deleted, the object representing some things may not be deleted. Group
When a composite object is deleted, the object representing some things is also deleted.

Instance analysis

Unicom customers respond to OSS. The system provides function modules such as fault tickets, Service Activation, resource verification, cutover, service re-protection, and network quality and performance. Now we will explain some of the requirements as an example.

You can refer to the class diagram for better understanding.

1. notifications include general notifications, cutover notifications, and reinsurance notifications. This is an inheritance relationship.

2. noticeservice and the implementation class noticeserviceimpl are implementation relationships.

3. noticeserviceimpl references notice through the Save parameter, which is a dependency. The basedao completion function is also called as a dependency.

4. cutover notification and fault ticket are generally associated by intermediate class (Notification circuit.

5. There is an aggregation relationship between the warranty notice and the pre-plan database. Because the pre-plan library can be input in advance, and there is no necessary link with the re-Warranty notification, it can exist independently. In the system, manually select from the list. Delete the re-Warranty notification without affecting the plan.

6. There is an aggregation relationship between cutover notification and request ticket. Similarly, a request ticket can exist independently of a cutover notification. That is to say, the cutover notification is deleted without affecting the ticket.

7. Notifications and replies are in a combination. Because the reply cannot exist independently of the notification. That is to say, to delete a notification, the corresponding reply to the notification should also be deleted in a cascade manner.

After the above analysis, I believe you have a good understanding of the relationship between classes. Do you have any other ideas or good opinions.

PS: Well, the above class diagram is drawn using enterprise definition 7.5. We recommend EA here, which is very good. It can replace Visio and Rose. Visio is not powerful enough, and Rose is too heavy. Only EA is suitable.

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.