Detailed description of the relationship between UML class diagrams and classes-UML Yibo stream Series

Source: Internet
Author: User

This article from: http://www.iteye.com/topic/979557

 

After summing up Ubuntu, we will continue to integrate UML. In the previous article, we introduced the Relationship Between the use case diagram and the use case. Let's talk about it now.Relationship between class diagrams and classes in UML.

When drawing a class chart, clarifying the relationship between classes is the focus. Class relationships include generalization, implementation, dependency, and association ). The Association is divided into general association, aggregation, and 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.Is the basis for defining other graphs. 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, 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.CodeIt generally refers to the call relationship between other objects established by local variables, function parameters, and return values. A class call is dependent on some methods in the class to fulfill some of the class's responsibilities.In the class chart, use a dotted line with an arrow to indicate that the arrow points from the 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: indicates the relationship between has-a, which is an unstable inclusion relationship. It is stronger than general association and has a general and local relationship,Without the whole, the part can also exist independently.. 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: indicates the contains-a relationship, which is a strong inclusive 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, if the relationship between the company and the Department is absent, the Department cannot exist. The relationship between the problem and option in the questionnaire; the relationship between the order and the order option.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 "has-a", and the combination relationship is "contains-a". The aggregation relationship indicates that the relationship between the whole and the part is relatively weak, 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 aggregation object is deleted, the Objects representing some things are not necessarily deleted. Once a composite object is deleted in the composite, 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.