UML learning Summary

Source: Internet
Author: User

I recently used status mode to write an MFC similar to Windows Calculator.ProgramBy the way, I learned how to draw UML diagrams, especially class diagrams and state diagrams. Let's make a summary here.

1. Introduction to UML

Unified Modeling Language (UML ):It is a standard language for Visual Modeling of software systems.

(1) In the development stage, UML is used to describe, visualize, build, and write An Object-Oriented software product design language. (2) UML can run through every stage of the software development cycle. QuiltOMG(Object Management Organization) adopts as the industry standard. (3) UML is most suitable for data modeling, business modeling, object modeling, and component modeling. (4) UML enables software developers to focus on building product models and structures.

After the model is created,A model can be converted into a specified programming language by a UML tool.Code.

Currently, the mainUMLToolsInclude:RationalCompanyRose(Rose),Together
SoftCompanyTogether,MicrosoftVisio.

 

Ii. Relationship between UML class diagrams

In a UML diagram, there are several common relationships: generalization, implementation, association, aggregation, and composition ), dependency)

1. Generalization)

[Generalized relationship]: an inherited relationship that represents a general and special relationship. It specifies how child classes feature all features and behaviors of the parent class. For example, a tiger is a type of animal, that is, the characteristics of a tiger and that of animals.

[Arrow pointing]: solid line with a triangular arrow. the arrow points to the parent class.

2. Implementation)

[Implementation relationship]: The relationship between a class and an interface, indicating that a class is the implementation of all features and behaviors of an interface.

[Arrow pointing]: dotted line with a triangular arrow. the arrow points to the interface.

For example, a pigeon (PIGEON) is a type of bird that can implement a flight interface.

 

3. Association)

[Association]: A relationship that enables a class to know the attributes and methods of another class. For example, the relationship between a teacher and a student, and between a husband and a wife can be bidirectional, it can also be unidirectional. Two-way association can have two arrows or no arrows, and one-way Association has one arrow.

[Code embodiment]: member variables

[Arrow and direction]: solid line with a normal arrow, pointing to the owner

 

4. Aggregation)

[Aggregation relationship]: The relationship between the whole and the part, and the part can exist independently from the whole. If a car and a tire are in the overall and partial relationship, the tire can still exist when it leaves the car.

An aggregation relationship is a strong association relationship. The association and aggregation cannot be distinguished in syntax, and the specific logical relationship must be investigated.

[Code embodiment]: member variables

[Arrow and direction]: solid line with hollow diamond. The diamond points to the whole.

 

5. Composition)

[Composite relationship]: it is the relationship between the whole and the part, but the part cannot exist independently from the whole. If the relationship between a company and a department is a whole and a part, no department exists without the company.

A composite relationship is a type of association relationship, which is stronger than an aggregation relationship. It requires that the object representing the whole in a general aggregation relationship represents the lifecycle of some objects.

[Code embodiment]: member variables

[Arrow and direction]: solid line with solid diamond. The diamond points to the whole.

 

6. Dependency)

[Dependency]: it is a type of use relationship, that is, the implementation of a class requires the assistance of another class, so try not to use two-way mutual dependency.

[Code representation]: local variables, method parameters, or calls to static methods

[Arrow and direction]: a dotted line with an arrow pointing to the user

Strong and weak order of various links:

Generalization = implementation> combination> aggregation> association> dependency

Summary of the above UML class diagramTransferred from:Http://blog.csdn.net/tianhai110/article/details/6339565This blog also provides several ways to draw graph relationships. The authors use vs2010 to draw class diagrams. Of course, they can also use rose and Visio tools to draw class diagrams.

 

 

 

 

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.