While it is fairly obvious to choose between writing a macro or developing a module with some practice it may not be at the beginning.

What is a macro ?

A macro is a jython (python on Java virtual machine) program that navigates through, creates or modifies model elements. It can be associated with a menu entry or toolbar button or it can be written and executed directly from the macro window. It can also have its own GUI.

Comparison between macro and module

Feature Module Macro

Model navigation, modification, creation

Yes

Yes

Definition of stereotype, tag type, note type.

Yes

No

Definition of property page

Yes

No

Menu customization

Yes

Limited : at best it can have it’s own menu entry under ‘Macro’ entry or a button in the tool bar

Menu customization responsibility

Module developer

Macro user

Definition of parameter

Yes

No

Definition of palette tool

Yes

No

Model event handler

Yes

No

Delivery format

A jmdac archive with jar files, icons, internationalized messages

A python file

Back to the initial question, a macro will be preferred to a module when:

  • no extension is required (stereotype, etc);

  • its use is limited (model transformation or correction at module version update);

  • sources are not expected to be managed apart (a macro is a python source file);

  • there are no strong constraints on the maintenance of the macro

  • there are no needs for a real development cycle of the macro

Developing a module is more time and resource consuming because it involves to tweak XML files, to write Java code, to compile, to package module, etc. However, developing a module is a real development project that can be managed : life-cycle, versions, patches and so on. Developing a module as a real development project can be carried out in a very efficient and natural way using Modelio Studio.

About execution speed of model transformations, just note that macros are also impressively fast to process large models. So processing time is definitively not an essential criterion to choose between macro and module.

The rule of thumb is : Develop a module if you need more than what a macro can provide.

<< Previous

Index

Next >>