Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Generate a Single Class

To generate code for a single Class, first ensure the design of the model element (Class or Interface) is complete. Also ensure you have added Inheritance connectors to parents and associations to other Classes that are used. Also add Inheritance connectors to Interfaces that your Class implements; Enterprise Architect offers the option to generate function stubs for all interface methods that a Class implements. Once the design is satisfactory, follow the procedure below.

How to

To generate code for a single Class

Step

Action

See also

1

Open the diagram containing the Class or Interface for which to generate code.

 

 

2

Right-click on the required Class or Interface and select the Generate Code context menu option, or press ( F11 ).

The Generate Code dialog displays, which enables you to control how and where your source code is generated.

 

 

3

On the Path field, click on (  ...  )  (Browse) and select a path name for your source code to be generated to.

 

 

4

In the Target Language field, click on the drop-down arrow and select the language to generate; this becomes the permanent option for that Class, so change it back if you are only doing one pass in another language.

 

 

5

Click on the Advanced button.

The Object Options dialog displays.

 

 

6

Set any custom options (for this Class alone), then click on the Close button to return to the Generate Code dialog.

 

 

7

In the Import(s) / Header(s) fields, type any import statements, #includes or other header information.

Note that in the case of Visual Basic this information is ignored; in the case of Java the two import text boxes are merged; and in the case of C++ the first import text area is placed in the header file and the second in the body (.cpp) file.

 

 

8

Click on the Generate button to create the source code.

 

 

9

When complete, click on the View button to see what has been generated.

Note that you should set up your default viewer/editor for each language type first; you can also set up the default editor on the Code Editors page of the Options dialog (Tools | Options | Source Code Engineering | Code Editors).

 

Editing Source Code

Learning Center topics

(Alt+F1) | Software Engineering | Generate Code | Generate a Single Class