Comparison of Java reverse engineering functions of several development tools

Source: Internet
Author: User
Tags dot net

I recently took over the Java maintenance project iDrive, and there are not many code, which is about 5 ~ About 6 K, but the relationship is a little messy, so I want to use EA reverse engineering to directly generate a UML diagram from the Java code, which helps me quickly understand the code results.

After searching, the following document is worth your reference.

 

 

====================== Use eclipse to generate a UML diagram

Over the years of software development, I have read a lot of mature software source code. by referring to the design concepts of advanced software, I have avoided many detours. Years of Experience tell me that if we want to make rapid progress in software architecture design, we can only stand on the shoulders of giants. Reverse Engineering is a shortcut to the shoulders of giants. However, people who have done reverse engineering know that it is not easy to reverse engineer the source code and explore the designer's design concepts and intentions. However, as long as you have mastered some methods and techniques, reverse engineering is not impossible. This article focuses on reverse engineering for the Java language and is not fully applicable to other languages.

Basic methods and steps for reverse engineering:
1. Software functional trial.
Input: User Manual, feature list, and software release.
Output: Use Case)
Method: Software trial.

2. Code dynamic structure analysis, also known as functional flow analysis.
Purpose: The function flow is the core of the software. It represents the software implementation method and determines the basic architecture of the software.
Input: source code, use case
Output: Activity diagram and sequence diagram.
Methods: There are two methods available: Dynamic and Static. Dynamic means include setting the break point and viewing the call stack. Static means include directly tracing function calls through the integrated development environment (IDE, including forward tracing (direct view of called functions) and reverse tracing (query function callers (reference), or using the UML reverse engineering tool to generate a sequence diagram (sequence diering) directly from the code)

3. Static code structure analysis, also known as module structure analysis.
Objective: To enhance code reusability, maintainability, and scalability, the main function of static structure is to enhance code reusability. By analyzing the static structure of the code, we can get the code reuse mode.
Input: design document, similar to the code structure document of Java Doc, source code.
Output: module structure diagram, class diagram.
Method: Use the UML reverse engineering tool to generate class digraphs directly from the code ). Observe the Code Organization (directory structure ).

1. Eclipse
Eclipse is my favorite Java Development Tool. Excellent human-computer interaction interfaces bring great convenience to developers. The rich plug-ins make eclipse easier to expand and customize. It also provides the most concise and rich functions in source code reverse engineering.
For the dynamic analysis of source code, Eclipse's jdt provides direct function jump, call hierarchy, reference search, and read access search for variables ), write Access search for a variable, declaration search for a function or variable ). Most importantly, eclipse provides a powerful Java integrated debugging environment.
For Static Analysis of source code, jdt provides a type tree (type hierarchy) and an interface to implement search (implementor search ).

If you want to present the information in a UML diagram, you can use together eclipse to dynamically associate the source code with the model. It also provides a wide range of UML reverse generation functions. However, together eclipse has high requirements on PC configuration. It is barely usable in the author's amd sempron 2200/512 M/80g configuration. If you want to analyze projects with millions of lines of source code, this software consumes too much PC resources, which is not recommended by individuals.

Eclipse has provided a complete reverse engineering function. Although it is not ideal to combine with UML, I strongly recommend eclipse. The reason is very simple. It is easier to give the software design graphical work to the brain. The most necessary function is to get the source code information we want at any time. Eclipse has become a peak in this regard.

================================ Generate a UML diagram from Java through EA

The main task is to import the source package to EA, and then use the reverse engineering in it to automatically generate a UML diagram.

1. First, create a project to check the class
2. Right-click any folder in the project, select code engineering, and select import source directory.
3. Then, make necessary settings. For example, if you select the language UML, what is displayed?
4. After all the data is imported, you can find these UML diagrams in the project browser and click a small icon with the same tree structure at the bottom of the screen to automatically arrange them.

Classes in 5 packages can be pasted into any UML diagram. If they are related to the UML, for example, a subclass of the classes in the package, EA automatically forms a relationship after the post is pasted.

==================== Connection method between EA and eclipse

This section describes the connection between eclipse and the UML tool EA. The connection involves four steps, we hope that you can learn how to connect eclipse and UML tools to EA through this section. The following is a detailed introduction.

How to connect eclipse and UML tools EA

EA (enterprisearchitect) is very small and only 30 m. It does not have high computer requirements, but has more functions than other software. Comprehensive support for uml2.0, more in line with UML specifications than other tools. Supports forward code generation and reverse UML diagram generation in Java, C, dephi, C #, PHP, VB, and other languages. EA has Windows and Linux versions. It can be connected to development tools such as Eclipse and Dot NET through the mdglink tool. UML diagrams and code are generated from each other. What you see is what you get.
There are not many articles about ea on the Internet. This article is close-up, hoping to help people who use eclipse and use UML to design projects.

Running requirements:
Ecplise3.1.x (3.2 not tested, I don't know how)
Windows XP
Or windows2000sp4
Remember this. Otherwise, the installation will fail.

1. Download

First download the UML tool EA address: http://www.sparxsystems.com.au/products/ea_downloads.html
Download the tool mdglinkforeclipse for connecting EA and eclipse. The address is:

Http://www.sparxsystems.com.au/products/mdg_eclipse.html

The above two tools are all for 30 days, but they are enough.
Eclipse doesn't need to be said. I used 3.1. I downloaded the language plug-in and changed it to the Chinese version. The help was all in Chinese.

2. Installation

After that, install the umltool eaand run easetup.exe.
Then install the eaecplise.zip file of the mdglinkforeclipse, in two steps.
Step 1: Decompress eaecplise.zip with a jar and an EXE file. Copy the JAR file to the Plugins directory of your ecplise. For example, D: \ eclipse \ plugins
This jar file has a version. For example, org. sparx. MDG. eclipse_1.0.19.jar. The version is 1.0.19. Make sure that there are no other versions of this file under the D: \ eclipse \ plugins directory.
Step 2: run the exefile, unzip eaw.se.exe, and install it.

Run the UML tool EA. If mdglink is successfully installed, there should be an add_ins directory behind the tools directory of the main menu of EA. If this directory does not exist, the link installation is unsuccessful. EA can use it, but cannot connect to eclipse. For more information, see the help documentation in eaeclipse.zip.
Click add_ins/Eclipse/optionto enter your eclipse.exe address, for example, \ eclipse \ eclipse.exe.

3. Connect the Eclipse project and the UML tool EA Project

Click file/newproject in the main menu of EA to create an EA project.
Click add_ins/connectexternalproject/ecplise in the main menu. A dialog window is displayed, and eclipse is automatically started. It is okay to start eclipse in advance.
In the lower part of the EA dialog window, select the ecplise project and click Connect. The project connection is complete.

4. Implement UML and Code Synchronization

Click add_ins/meragewitheclipse In the UML tool EA. A window is displayed. selecttype in the window selects the synchronization mode, and none generates only the UML class diagram. Forward generates code positively, it is to convert the UML diagram in EA into a Java file in the Eclipse project; reverse is a reverse engineering, that is, to generate a UML diagram for the code in the ecplise project; both is the meaning of forward and backward at the same time.
The connection is complete.

!!! Remember: mdglink does not support Chinese characters. After forward or both is selected, the Chinese comments of the programs in the ecplise project will become garbled characters !!!

In addition, the class code generated using the class diagram of EA always generates a method at the end. In ecplise, an error is reported and you can delete it. In addition, you can remove this method by modifying the generate program template in EA.

 

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.