Modeling Wizard patterns enable you to significantly improve productivity, coherence and traceability, by creating elements from other elements through deduction.
For example, from an object present in a sequence diagram, you can create a class whose operations will be deduced directly from the messages received by the object.
Modeling Wizard patterns are run from the “Modeling Wizard” item in the context menus available on certain elements in the “Model” view and Modelio diagrams.
The following list shows which Modeling Wizard patterns are available on which model elements.
Instance:
Lifeline:
Message:
Attribute link:
Transition:
Interface:
Class:
The “Create a classifier from this instance” pattern creates a classifier and its contents from a selected instance and the operations it receives.
In the example shown below, we are going to create a class from the “B” instance and an operation from the sequence message belonging to this instance.
Steps:
Right-click on the “B” instance to open the context menu, and then run the “Modeling Wizard/Create classifier from this instance” command.
A Modeling Wizard window then appears, asking you to enter a name and a type for the classifier you are about to create. By default, the name of the classifier will be the same as the name of the object from which the command is being run, and the type will be class. Enter a name and press “OK” to confirm.
Where necessary, additional Modeling Wizard windows appear, asking you to enter a name for each operation you are about to create. As before, simply enter a name and confirm by clicking on “OK”.
If the instance has attribute links, additional Modeling Wizard windows appear, in which you can enter a name for each attribute you are about to create. Once again, simply enter a name and then confirm by clicking on “OK”.
The result of this operation is that the newly created “B” class appears in the “Model” view and also in the sequence diagram as the class instanciated by the “B” instance.
The newly created operations also appear in the “Model” view and in the sequence diagram as the operations invoked by the sequence messages that are received by the “B” instance.
The attributes created appear in the “Model” view as the base attributes of the attribute links.
The “Update instance or part from the classifier” pattern updates the contents of an instance or part with regard to a classifier.
If the instance or the part instantiates a classifier, it is updated with regard to this classifier. This includes attributes, ports and required and provided interfaces.
If the instance or the part is not linked to a classifier, you can carry out an update with regard to a classifier that exists in the same package.
The “Create an operation from this message” pattern creates an operation from a selected sequence message.
This pattern is run in the same way as the “Create a classifier from this instance” pattern presented earlier.
After the pattern is applied, the newly created operation appears in the “Model” view and also in the sequence diagram (as the operation invoked by the selected sequence message).
The “Create an attribute from this occurrence” pattern is used to create an attribute from a selected attribute link.
This pattern is run in the same way as the “Create a classifier from this instance” pattern presented earlier.
After the pattern is applied, the newly created attribute appears in the “Model” view as the base attribute of the selected attribute link.
The “Create an operation from this transition” pattern is used to create an operation from a selected transition. This pattern can only be used on transitions in state diagrams associated with classes.
This pattern is run in the same way as the “Create a classifier from this instance” pattern presented earlier.
After the pattern is applied, the newly created operation appears in the “Model” view and also in the state diagram (as the expression of the action of the transition).
The “Implement interface properties” pattern is used to automatically implement the services provided by an interface class in an implementation class.
In the example shown below, we are going to run the “Implement interface properties” pattern on the implementation class named “ImplInterface”, so as to automatically implement the three operations contained within the interface class named “Interface1”.
Note: Make sure that your implementation class implements the interface class (by creating an implementation link from the implementation class to the interface class).
Steps:
Right-click on the “ImplInterface” implementation class to open the associated context menu.
Run the “Implement interface properties” pattern.
The result of the operation shown above is that the “ImplInterface” implementation class now contains the three services belonging to the “Interface1” interface class (as shown below).
The “Delete interface properties implementations” pattern is used to delete the services provided by an interface class from an implementation class.
This pattern is run in the same way as the “Create a classifier from this instance” pattern presented earlier.
Note: This pattern is the opposite of the “Implement interface properties” pattern presented above.
The “Update internal structure” pattern is used to automatically update the parts instantiated in the internal structure of a class.
All the parts that instantiate a classifier are updated with regard to the classifier. This includes attributes, ports and provided and required interfaces.
For every part that is not linked to a classifier, you can choose an classifier that exists in the same package as the class, or else create one from the part itself.
In the example shown below, we are going to run the “Update internal structure” pattern on the “Robot” class, in order to automatically create the internal structure of classes, ports and required and provided interfaces.
The result of the operation shown above is that the “Robot” class now contains the complete internal structure previously created, as shown in the screenshot below.