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



See also


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




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.




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




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.




Click on the Advanced button.

The Object Options dialog displays.




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




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.




Click on the Generate button to create the source code.




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