Code Generation - Turn Your Diagram to Code

Transform UML to code. Our code generator allows you to convert your diagrams to source code in various programming languages. Mostly, you will need to build codes and scripts for UML class diagrams or entity-relationship diagrams. However, you can also generate code from a UML state machine diagram or any other diagram type with custom-defined templates.

UML Code Generator

Software Ideas Modeler is a feature-rich UML tool that allows you to generate code in various programming and scripting languages very easily. UML code generator supports the following programming languages with the pre-defined generation templates:

Diagram Editor with Code Generation Sidebar
Diagram Editor with Code Generation Sidebar

UML to Code

Software Ideas Modeler can generate code from UML diagrams. There are pre-defined templates that allow you to turn your UML Class Diagram with all the classes, interfaces, enumerations, and various relationships to source code in Java, C#, Python, C++, or other languages.

You can specify logical (UML) types for the attributes and operation and the generator will transform them into correct types in the target language. If there is a need for language-specific types that cannot be resolved from the general logic types, you can use a type set for the specific language directly in the diagram - then the exact type will be used.

How to Generate Code for a Diagram?

There are two ways how to generate source code for a diagram - using the Generation sidebar or the Generation dialog.

The fastest way is to use the Generation sidebar. (It can be displayed from Ribbon/View tab/Window group/Sidebars drop-down/Generation). The sidebar allows you to generate code for the active diagram or only for the selected elements in the diagram editor. So you can easily generate code snippets and copy them from the code editor inside the sidebar.

How to Generate Code for Multiple Diagrams or Whole Project?

You can also generate the source code from UML using the Source Code Generation dialog. It is useful when you want to generate code for the whole project or more diagram at once. You can open it from the ribbon - Process tab / Generation group / Source Code button.

You can choose which diagrams you want to generate in the Source Code Generation dialog. The dialog supports searching in the project tree and offers the button for multiple node selection.

Source Code Generation Dialog
Working with Source Code Generation dialog

The dialog window is divided into two parts - a project tree on the left and a tab control with generation options on the right.

The project tree allows you to choose diagram elements for which you want to generate source code. You can select all nodes or only some folders or diagrams.

The dialog includes the following tabs: General, Imports, and Template Options.

The General tab offers main generation options. You can choose here which language and template you want to use. Some languages can offer multiple templates. You need to specify where should be the output code generated using the Output directory box. You can enter a local folder path to the box, or you can click on the button with the ellipsis on the right and choose a folder from the folder tree in the dialog.

Another option on the General tab is Encoding. The default encoding is UTF-8, but you can change it to one of the other standard options.

The following options allow you to adjust the organization of the generated code:

  • Create subdirectories for packages - if checked, a hierarchy of folders will be created by project folders and packages. If unchecked, all files will be placed in the output directory without creating any additional subfolders.
  • One file per diagram - the code for elements in one diagram will be generated into one file.

The Imports tab allows you to specify additional external packages that should be included in the source code files through imports and usings. The tab contains Add and Remove button for list editing. The buttons with the up and down arrows allow you to reorder the list.

Template Options tab contains template-specific settings. They may vary from template to template. Many templates offer at least these options:

  • Indentation char - specifies the character used for code indentation - it can be a space or tab.
  • Indentation size - specifies the number of indentation characters used for a single indentation level.

Unsupported Language or Diagram to Code Transformation

If you need to transform the diagram into code for a specific programming language or a framework in a defined language, you can do it. Software Ideas Modeler provides source code template language which allows you to define any template for any diagram type you want. You may even add a new programming language.

Comments

satty 25 November 2020 0:24:54

need software

Hope you doing.

Need to understand the software, what is the pricing for this.

Dusan Rodina - softwareideas.net 25 November 2020 7:40:38

RE: need software

Hello,

Thank you for your interest. You can find the current pricing here: https://www.softwareideas.net/en/purchase

The feature comparison is available here: https://www.softwareideas.net/en/edition-comparison

For code generation, Premium edition is sufficient, which costs $109.

Fatima 27 November 2021 15:30:26

CIB 3103

diagrams to codes

Daan 8 September 2023 13:29:54

generate C++ code out state machine

Hello,

I can generate c++ code with a class diagram, but I want the same with a state machine. But it doesn't work. Should it been done in an other way?

Dusan Rodina - softwareideas.net 8 September 2023 18:19:08

RE: generate C++ code out state machine

Hello,

Unfortunately, generating C++ code for UML state machines is not yet supported. It is only for C# and JavaScript. We can add support for the state machine to C++ generation in one of the next versions.

Rastislav jelinek 22 March 2024 22:47:12

RE: RE: generate C++ code out state machine

Hello, I would like to ask about the plans of adding support for C++ or C in your software. I am currently working on my bachelor's thesis under the patronage of BSH Corporation, focusing on software capable of generating code in C/C++. However, it needs to offer more than just generating class diagrams. I am very impressed by your product in the demo version, and I would be thrilled if this feature is planned to be add in the future.

Dusan Rodina - softwareideas.net 25 March 2024 9:37:26

RE: RE: RE: generate C++ code out state machine

Hello,

Thank you for your interest in Software Ideas Modeler and your kind words! We're planning to introduce C++ code generation for state machines most likely in version 14.40.

New Comment

Comment