Modeling Wizard patterns

Introduction

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.

Patterns available

The following list shows which Modeling Wizard patterns are available on which model elements.

Instance:

  • Create a classifier from this instance: Creation of a classifier and its contents from the instance and the received operations. If the instance has ports, the element created can be a class or a component. Otherwise, it can also be an interface or a node.
  • Update instance or part from the classifier: Updates the ports and attribute links of the instance with regard to the instanciated classifier. If the instance is not linked to a classifier, it is possible to choose an existing classifier in the same package as the instance.

Lifeline:

  • Create a classifier from this instance: Applies the pattern described above to the instance represented by the lifeline. The instance is also created if it does not already exist.
  • Update instance or part from the classifier: Applies the pattern described above to the instance represented by the lifeline. The instance is also created if it does not already exist.

Message:

  • Create an operation from this message: Creation of an operation from a message. If the class did not already exist, it is also created.

Attribute link:

  • Create an attribute from this occurrence: Creation of an attribute from an attribute link. If the class did not already exist, it is also created.

Transition:

  • Create an operation from this transition: Creation of an operation from the transition. This pattern can only be used in state diagrams associated with classes.

Interface:

  • Update classes from this interface: Updates all classes implementing the interface from the interfaces content.

Class:

  • Implement Interfaces properties: Creation of the operations defined in the interfaces that are implemented by the selected class.
  • Delete Interface properties implementations:Deletion of the operations defined in the interfaces which are implemented by the selected class.
  • Update internal structure: Update of the parts instantiated in the internal structure of the class.

The “Create a classifier from this instance” pattern

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.

2

Using the “Create a classifier from this instance” pattern

Steps:

  1. Right-click on the “B” instance to open the context menu, and then run the “Modeling Wizard/Create classifier from this instance” command.

  2. 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.

  3. 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”.

  4. 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.

3

The result obtained after running the “Create a classifier from this instance” pattern

The “Update instance or part from the classifier” pattern

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

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

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

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

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).

4

Using the “Implement interface properties” pattern

Steps:

  1. Right-click on the “ImplInterface” implementation class to open the associated context menu.

  2. 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).

5

The result obtained after running the “Implement interface properties” pattern

The “Delete interface properties implementations” pattern

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

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.

6

Using the “Update internal structure” pattern

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.

7

The result obtained after running the “Update internal structure” pattern

modeler_fig_57.gif (48 KB) admin admin, 12 June 2012 16:23

modeler_fig_56.gif (99.4 KB) admin admin, 12 June 2012 16:23

modeler_fig_52.gif (124 KB) admin admin, 12 June 2012 16:23

modeler_fig_54.gif (46.4 KB) admin admin, 12 June 2012 16:23

modeler_fig_53.gif (40.7 KB) admin admin, 12 June 2012 16:23

modeler_fig_55.gif (34.9 KB) admin admin, 12 June 2012 16:23