UML Wizard logo

How to Generate Code

Turn a class diagram into source code in C#, Java, Kotlin, TypeScript, Ruby or C++, or in any language added with a plug-in.

Generate code from a class diagram

  1. Select a class diagram in the Project Explorer. If it is open, it is generated as shown, including unsaved changes.
  2. Choose Diagram → Generate Code…
  3. Pick the Language.
  4. Enter the Namespace (package in Java and Kotlin, module in Ruby; in TypeScript, the folders of the files). It is optional, e.g. Shop.Domain or Shop::Domain. The project name is suggested.
  5. Choose the Output folder. It is created if needed; Generated/<language> next to the project file is suggested.
  6. Check the list of files: those that would replace existing files are marked. Read the Notes on the generated code for anything the language cannot express.
  7. Click OK. You are asked before existing files are replaced.

What the diagram becomes

DiagramC#JavaKotlinTypeScriptRubyC++ (C++17)
FilesOrder.csshop/domain/Order.javashop/domain/Order.ktshop/domain/Order.tsshop/domain/order.rbOrder.h, and Order.cpp when there are stubs
Classclass, abstract classclass, abstract classclass (open when extended), abstract classclass, abstract classclassclass; abstract operations are pure virtual
Interfaceinterfaceinterfaceinterfaceinterfacemodule, included by the classes that realize itclass with pure virtual functions
Enumerationenumenumenum classenummodule of constantsenum class
Attributeauto-property, or _field when privatefieldproperty: lateinit, or a zero value; static ones in a companion objectproperty (! when it has no value)attr_accessormember
Operationmethod that throws NotImplementedExceptionmethod that throws UnsupportedOperationExceptionfunction that calls TODO()method that throws Errormethod that raises NotImplementedErrordeclaration, and a definition that throws std::logic_error
Operation named like its classconstructor (initialize in Ruby)

Relationships, notes and types

Add another language

Every language is a plug-in: a .NET DLL that UML Wizard loads when it starts. The built-in ones are in the plugins folder next to UML Wizard. To add one, copy its DLL into your own plug-ins folder, %APPDATA%\UmlWizard\plugins on Windows or ~/.config/UmlWizard/plugins on macOS and Linux (create it if needed), as Name.dll or, with its dependencies, Name/Name.dll. Restart UML Wizard: the language appears in the Language box. To remove one, delete it and restart.

Only install plug-ins you trust: a plug-in runs inside UML Wizard with your permissions.