-
Notifications
You must be signed in to change notification settings - Fork 130
Module_or_macro
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.
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.
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)
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.
Macros are also impressively fast to process large models. So processing time is definitively not a criterion to choose between macro and module.
The rule of thumb is : Never develop a new module when a macro can do it.
For more information about macros, see Scripts and Macros.