UML Design Via Visual studio-class Diagram

Source: Internet
Author: User

Using a few modeling design tools, small have staruml, large have rational rose,ea. The final discovery or Visual Studio modeling is more comfortable (personal view, don't argue).

I'm going to make an introduction to a few of the modeling diagrams that I use often, such as Class diagram (class Diagram), Time series diagram (sequence Diagram), use case diagrams (using cases Giagram), Component Diagrams (component Diagram), layered graphs (layer diagram).

This article focuses on designing the class diagram in Visual Studio, which mainly includes the following:

  1. VS Modeling Project Introduction
  2. Class Diagram creation
  3. Description of relationship between classes
  4. Generate code automatically based on class diagram

VS Modeling Project Introduction

To model with Visual Studio, you first have to create a modeling Project.

After creation, project is as follows:

All of the next modeling in VS can be done in this project. You can create all vs supported models in project by right-clicking the ADD new item.

You can create a class drawing cloth for class design by selecting UML class diagram in.

Class Diagram creation

You can create a class diagram by using the tool box on the left, demonstrating the relationships of interfaces, classes, and classes: inheritance, dependency, aggregation, and composition. Enum is no longer demonstrated, package is a sub-design class diagram, the class diagram design in the packages, the personal feel that the use of small, if you need to sub-package to create a new class diagram file it. The size of the screen is limited, and it is unrealistic to put the entire system's class diagram into a single artboard and no longer demonstrate it.

Description of relationship between classes

The class diagram above shows "Inheritance (inheritance), dependency (dependence), aggregation (aggregation), Combinatorial (composition)" Three types of relationships, in fact there is an association (association) (People to Country), which is a very weak relationship between classes, only visually tells people that there is an association between classes. Inheritance is understood, the following highlights the other three.

Dependency: Class A relies on B, which refers to the use of a method's parameter in Class A, the method body, or the return value of a method. The person in person relies on mail

Aggregation: A class and Class B aggregation, is only a class is a property of Class B, but Class B can exist separately, in person and Book,book is the property of person, but book can exist separately

Combination: The combination is similar to the aggregation is also the whole part of the relationship, the relationship between person and hand, hand as a person's attribute exists, the difference is the person and hand life cycle.

Aggregation and composition are the same in the program structure itself, but separate to understand the design and the life cycle of the object from the diagram.

Generate code automatically based on class diagram

Under VS, you can generate code based on the class diagram above, right-click on the artboard:

The generated code is as follows (the class's build directory is optional):

You can see that book,hand,country as shown in the class diagram exists as a property of person.

These are some of my summaries of creating class diagrams below Vs, which is useful for team communication. The final version of a key to generate code, productivity also went up.

Other modification properties, such as whether it is abstract or public, are no longer demonstrated.

UML Design Via Visual studio-class Diagram

Related Article

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.