Creational Wizard

Often when you add a field or property you need to add code to the class constructor or destructor to initialize or finalize the member.
The Creational Wizard is used to centralize this process and define initialization / finalization code while you add the member.
Optionally a parameter is added to the constructor parameter list to initialize a member. You may select an existing constructor or create a new one.
Similar finalization snippets can be inserted in a new or existing destructor.
MMX Code Explorer includes this wizard.

Pascal Example: adding a field with constructor / destructor code

Assume you have a class TDocument and want to add a field FLines: TStrings to store the contents like this:

Creational Wizard: add field dialog

…then usually you need to add a constructor with code that instantiates FLines and add a destructor with code to dispose the lines again, for example like this:


This is exactly what the wizard does! Go to the Creational Wizard Tab, and click the “Composition” preset:

Creational Wizard: Composition preset

This preset selects a constructor and destructor and suggests code snippets, based on the field type and name.

Creational Wizard: add field dialog

after clicking OK, not only the field is inserted, but also the constructor, destructor and suggested code snippets.
Exactly as we wanted it! Instead of creating a new constructor, you can add the snippets to an existing constructor.


Pascal Example: initializing multiple fields and properties at once.

If you added a more fields and properties to your Document class, for example Header, Footer and Parent that all need
initialization code, you can invoke the Creational Wizard on the class itself.
This class wizard is similar to the one on the field and property dialogs, except that it shows all
fields and properties in a class and a preset can be applied to multiple selected members at once.

Creational Wizard: applied on class

… as you see in the above dialog, Header, Footer and Lines are initialized and destroyed, the Parent document is an aggregate reference.
Clicking OK results in the following code:


Customizing the wizard

The wizard is customizable using a type based look-up list in file CreationalWizard.txt in the shared directory,
for example “C:\Program Files\ModelMakerTools\Shared”. Here you define type initialization and finalization code per language.