Convert a Java file into a UML class diagram with MyEclipse

Source: Internet
Author: User

Convert a Java file into a UML class diagram with MyEclipse

Reference:

Convert Java files to UML class diagrams with MyEclipse-the world's most blog-csdn blog http://blog.csdn.net/dan15188387481/article/details/50053807

MyEclipse Draw UML Use case diagram and generate Java code (detailed steps)-Mushroom Hunter's column-Csdn blog http://blog.csdn.net/donggege214/article/details/48791413

The production of UML class diagrams is essential when   is learning design patterns or interacting with others in designing patterns. Usually, we will directly draw UML class diagram, for students, the general tool is Microsoft's Visio, this tool must be often used to draw a variety of diagrams, flowcharts, Network Diagram, flow chart, of course, can draw UML class diagram, use is very convenient, But the bottom of Visio is that it does not support the UML class diagram of Java, which is estimated to be Microsoft's own development, supporting home vs C and C + +. For the moment, how do Java Programmers draw UML class diagrams? You can create a UML project directly under Eclipse and then draw it according to the UML class diagram drawing method, but this is not the focus of this article. Many beginners or people who initially did not draw UML class diagram, after writing a project, want to overview of their own design of the Java program UML class diagram is what, this time to step by step to draw UML class diagram is too troublesome, it is estimated that we do not want to do this thing, So is there a way to convert a design directly into a UML class diagram for browsing? The answer is, of course: Yes. There are a number of ways to do this, and this article only describes one of the things I often use.      Readiness Tool: MyEclipse or Eclipse and UML plugin (Green), plugin link is: Click Open link      This article uses MyEclipse2015, This has cracked version, very useful, a lot of plug-ins have, so I have been using this, because it is in the school download, so there is no link, we can go online to find the next.      The first step is to prepare a project that has been designed with at least two or three classes and some interfaces, as well as their direct inheritance implementations, to make sense after the conversion. My project is shown in Figure 1.   Figure 1 Step 1     Second step, by clicking on New--other, according to the options in Figure 2, create a new UML model, here are two to choose, I prefer to use 2.   Figure 2 Step 2     Step three, after clicking on the new UML2 model, the following options will pop up, as shown in 3, where you need to select a UML folder.   Figure 3 Step 3     Fourth step, build the UML model after 4, and then you can directly in the inside to draw UML class diagram, but these steps for the direct conversion of Java files into UML class diagram is superfluous.   Figure 4 Step 4     Fifth step, is actually directly generated UMLThe first step of the class diagram. Take this project as an example, right-click on the project Package "Headfirst.adapter.ducks", then pop up a series of options, followed by click MyEclipse---Generate UML2 Class Diagram ..., the interface shown in Figure 5, Enter the name of the UML class diagram and click Finish to generate the UML class shown in Figure 6.    Figure 5 Step 5  Figure 6 generated UML class diagram      In short, the first four steps are about how to create a UML model and then use its drawing, The fifth step introduces the method of generating UML class diagrams directly from Java files in a project package. method is not limited to this one, welcome to add.   

Simply look at the directory structure and UML use case diagrams:

Directory Structure preview:

Use case diagram Previews:

Detailed steps (also not many, total five steps):

First, the new Java project

Open Myeclipse->new->java project-> Enter the project name (TV)->finish (if there is a pop-up window select Yes)

Ii. creating a UML use case diagram

Expand the project root first, right-click src->new->other-> in the list and expand Myeclipse-> and find UML in the expand item and expand->UML1 model->next-> name (TV)- >finish->yes (if you have some words Yes, no, forget it)

Third, Draw UML

According to the UML preview diagram above, the UML use case drawing out (this step is not difficult, according to the following steps the picture is OK, double-click the class diagram or the interface diagram in the corresponding location can be entered in the code in the diagram)

Iv. generating Java classes from UML

Select Uml->generate java...->select all->finish->yes in the menu bar (if you do not save the use case diagram, the Save prompt pops up, choose Yes)

V. Complementary and complete

The code in each of the generated classes is also fully supplemented, because the methods in the class are empty

Fill out other auxiliary classes and files

Convert a Java file into a UML class diagram with MyEclipse

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.