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

Generate Source Code


Generating source code (forward engineering) takes the UML Class or Interface model elements and creates a source code equivalent for future elaboration and compilation. By forward engineering code from the model, the mundane work involved with having to key in Classes and attributes and methods is avoided, and symmetry between model and code is ensured.




See also


Enterprise Architect supports code generation in each of the following languages:

·Action Script
·C# (for .NET 1.1, .NET 2.0 and .NET 4.0)
·C++ (standard, plus .NET managed C++ extensions)
·Java (including Java 1.5, Aspects and Generics)
·Visual Basic
·Visual Basic .NET




Code is generated from Class or Interface model elements, so you must create the required Class and Interface elements to generate from.

Add attributes (which become variables) and operations (which become methods).




Before you generate code, you should ensure the default settings for code generation match your requirements; set up the defaults to match your required language and preferences.

Preferences that you can define include default constructors and destructors, methods for interfaces and the Unicode options for created languages.

Languages such as Java support 'namespaces' and can be configured to specify a namespace root.

In addition to the default settings for generating code, Enterprise Architect facilitates setting specific generation options for each of the supported languages.

Source Code Options


ActionScript Options

C Options

C# Options

C++ Options

Delphi Options

Java Options

PHP Options

Python Options

Visual Basic Options

Visual Basic .NET Options


Code Template Framework

The Code Template Framework (CTF) enables you to customize the way Enterprise Architect generates source code and also enables generation of languages that are not specifically supported by Enterprise Architect.


Code Template Framework Tool

Local Paths

Local path names enable you to substitute tags for directory names

Local Paths

Local Paths Dialog


Behavioral Code

You can also generate code from three UML behavioral modeling paradigms:

·State Machine diagrams(SW & HW)
·Interaction (Sequence) diagrams (SW)
·Activity diagrams (SW)


Legacy State Machine Templates

Interaction (Sequence) diagrams

Activity diagrams

Live Code Generation

On the Code Engineering submenu, you have the option to update your source code instantly as you make changes to your model.


Code Engineering Options


When you generate code, you perform one or more of the following tasks:

·Generate a Single Class
·Generate a Group of Classes
·Generate a Package
·Update Package Contents


Generate a Single Class

Generate a Group of Classes

Generate a Package

Update Package Contents


·The tools provided by Enterprise Architect for code engineering and debugging are available in the Professional, Corporate, Business and Software Engineering, System Engineering and Ultimate editions of Enterprise Architect
·When security is enabled there are permissions for Generate Source Code and DDL and Reverse Engineer from DDL and Source Code

Learn more

Learning Center topics

·(Alt+F1) | Enterprise Architect | Software Engineering | Generate Code