Generate a Single Class

Return to Introduction  Previous page  Next page

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 links to parents and associations to other classes which are used. Also add inheritance links 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 steps below.

To Generate Code for a Single Class

1.Open the diagram containing the class or interface for which to generate code.
2.Right-click on the required class or interface to display the context menu and select the Generate Code menu option. The Generate Code dialog displays.
 
GenerateSingleElement
 
3.At the Path field, click on [...] (Browse) and select a path name for your source code.
4. Click on the Advanced button. The Source Code Engineering page of the Options dialog displays.
 
GenerateCodeAdvanced
5.Set any custom options (for this class alone), then click on the Close button.
6.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.)
7.Click on the Generate button to create the source code
8.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.

See Also