Book a Demo

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

Prev Next

Generate a Single Class

Before you generate code for a single Class, you:

  • Complete the design of the model element (Class or Interface)
  • Create Inheritance connectors to parents and Associations to other Classes that are used
  • Create Inheritance connectors to Interfaces that your Class implements; the system provides an option to generate function stubs for all interface methods that a Class implements

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

Click on the required Class or Interface and select the 'Develop > Source Code > Generate > Generate Single Element' ribbon option, or press F11.

The 'Generate Code' dialog displays, through which you can control how and where your source code is generated.

3

In the 'Path' field, click on the Browse. button 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, providing subsets of the 'Source Code Engineering' and code language options pages on the 'Preferences' dialog.

Source Code Options Language Options

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 Preferences window ('Start > Application > Preferences >  Preferences > Source Code Engineering > Code Editors').

Editing Source Code