Using Modeling Wizard patterns

 

Introduction

Modeling Wizard patterns are used to create elements from other elements through deduction, allowing you to significantly improve productivity, coherence and traceability.

 

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 context menus available on certain elements in the explorer and the graphic editors.

 

 

Patterns available

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

 

Pattern

Element

Result

Create a classifier from this instance

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.

Create a classifier from this instance

Lifeline

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

Instance

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

Update instance or part from the classifier

Lifeline

Applies the pattern described above to the instance represented by the lifeline. The instance is also created if it does not already exist.

Create an operation from this message

Message

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

Create an attribute from this occurence

Attribute link

Creation of an attribute from an attribute link. If the class did not already exist, it is also created.

Create an operation from this transition

Transition

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

Implement Interfaces properties

Class

Creation of the operations defined in the interfaces that are implemented by the selected class.

Delete Interface properties implementations

Class

Deletion of the operations defined in the interfaces which are implemented by the selected class.

Update internal structure

Class

Update of the parts instanciated in the internal structure of the class.

 

 

 

The "Create a classifier from this instance" pattern

The "Create a classifier from this instance" pattern is used to create 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.

 

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 "MDA Components/ModelingWizard/Create a 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 identical to 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 explorer and also in the sequence diagram as the class instanciated by the "B" instance. 

 

The newly created operations also appear in the explorer 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 explorer as the base attributes of the attribute links.

 

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 is used to update the contents of an instance or part with regard to a classifier.

 

If the instance or the part instanciates 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 is used to create 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 explorer 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 explorer 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 explorer 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).

 

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

 

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 instanciated in the internal structure of a class.

 

All the parts that instanciate 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.

 

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.

 

The result obtained after running the "Update internal structure" pattern