Java code generation and Graph Generation for Rational Rose Bidirectional Engineering

Source: Internet
Author: User

Rose's thinking is complex, its meaning is rich, its operations are awkward, its documents are simple, and its human nature is absent. However, I am afraid that the reason why people are eager for it is that our current teamleader, SA, is quite 'poisoned 'By the RUP, and this will also affect the disciples-Future SA.
Basic operations
1. Open rose


2. Select the default programming language by using tools> Options> notation> default> JAVA.

3. Create a file package test in the logical view (Logical Model)

Create a class and add attribute and operation.

1. generate code through model

Rose help is located at help> contents> rose Java> How to> forward engineer from rose to Java source

1 checking for Java syntax errors (check Java syntax errors)

When you try to convert a model component into a code framework, check whether the class to be generated has syntax errors.

A. Open your target digoal

B. Select the package or class you want to convert.

C. Click Tools> JAVA/J2EE> syntax check to check whether the target Code complies with the specifications, such as a naming error.

D. Check the inspection result in the Rose log window (below). If an error occurs, that is, errors, the generated code may not be compiled.

E. Correct these components or diagrams as needed

Assume that the above steps have completed the error

2. Select the package or class you want to convert

3. Click Tools> JAVA/J2EE> generate code.

In general, if you haven't mapped a package or component to a rose classpath directory (that is, to specify where to put the generated content ), the system will not allow you to click OK in the following interface, so now you can edit the target path.

4. Click the edit button under classpath entries, find new (insert) in the upper-right corner of the page (delete the one on the left), and select the target path in the newly added row in the list, you can select whether to generate a zip, jar, or directory. Specify the Directory and click OK. Then the path you selected is created successfully. Select this path and click OK to return to the interface (a lot of layers, the interface is ugly)

5. Now you can see that there is something in classpath entries. Select the package or component you want to convert in the list on the right, and click assign to assign it to the target classpth, theoretically, you can allocate multiple classptah objects to the selected package components or class diagrams. Click OK to generate

6. After successful execution, you can view the code under the specified classpath. The generated code has the relationship shown in the class diagram.

Class test1

Class Test2

Secondary reverse function

Rose help is located at help> contents> rose Java> How to> reverse engineer from Java source to Rose

Reverse engineering is the process of generating or updating a model through Java code. You can use rose to reverse the following files:

A. Java source code (. java files)

B. Java bytecodes (. class files)

C.zip,. Cab, And. Jar files

1. Open the model you want to create or update.

Open a model you just created or want to update

Create a new class digoal (if you still don't)

2. Click Tools> JAVA/J2EE> reverse engineer

Now you can imagine how Rose will do it. I just selected the graph, created the target path, and generated the code. Do you want to specify the path to read the file to generate the graph, you can say that again !! On the displayed page, select a classpath (if it already exists). Of course, you can also click the edit classpath button to create a new one (the page for creating a new path has just been mentioned, so it is no longer cumbersome ), then select this classpath, change the filter drop-down list below, and change the target file type (note that there are not only three lines, but you can scroll through it. You have a deep understanding of the spam on the Rose interface ), here we select. java, if this classptah exists. java files will be listed.

Note: You can add the selected file through add or add all columns, you can also recursively add all files and subdirectories in this path by adding recursive. You can see that Rose does not automatically list or even display any sub-directories (unattended). Select the file you want to reverse from the added file and click reverse to start creating or updating the file, if there is something wrong with it, you can make it right. If you have succeeded, click done to end the reverse interface and return to the main interface of Rose.

Note: Rose does not automatically generate graphs for the classes and components you reverse. The generated class is already listed under your class digoal according to the package relationship, you need to add them to your graph (depending on what you want to do). You have two ways to end this semi-automated reverse engineering process.

A manually drag the class or component to the target worker

B. Click query> add classes or query> Add components on the target graph interface. Select the view mode, which is generally logic view. Select the class or component to be dragged,> or all, click OK. The generated class diagram reflects the relationship between codes.

Three generate class diagrams

Drag class test1 and Test2 to class digraphs.

Generation sequence diagram

 

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.