Exercise 1: Creating the model environment

This exercise establishes the environment you need to apply a pattern.

You apply patterns to models that contain UML elements so that you can modify these elements. To do this, you need an open UML project and a UML model. For this tutorial you also need an open freeform or class diagram. Although the diagram view is not essential, using it to apply patterns makes it easier to see the pattern results.

If you are an advanced user, you can create a UML project, a UML model, and a freeform or class diagram if you are familiar with these tasks. To the model, add a UML class and a UML interface. The interface must define one or more operations. Ensure that the Modeling perspective is open. An easier option is to perform the following instructions to create these requirements for you. Advanced users can review these instructions to ensure that their results are the same as the example.

Loading the UML project and model

Follow these steps to import and open the initial UML project and model.
  1. Import the simple UML project by clicking: Samples Gallery. The Samples Gallery window opens.
  2. Click Technology samples > Patterns > Simple UML model and in the Simple UML model page click Import the sample.
  3. Click Finish to open the new project and model. The Model Explorer view opens.
  4. Expand the project and double-click the model. The model and a freeform diagram open.
Identify the diagram view by the name of the model on its tab. A new diagram view is a blank surface used to add and manipulate model elements. In this example, you see the class, named AppFunction, and the interface, named DoWork, are already displayed on to the freeform diagram. DoWork owns UML operations named doNothing and doSomething. The AppFunction class also owns two UML elements: an operation named Operation1 and an attribute named Attribute1.

Opening the Modeling Perspective

You can skip this task if the Modeling perspective is already open. If open, the word "Modeling" appears in the upper left-hand corner of the Workbench

Modeling perspective icon

The Modeling perspective provides ready access to the modeling tools and views needed for various functions that include applying patterns. Follow these steps to open the Modeling perspective.

  • Click Window > Open Perspective > Other.
  • In the Select Perspective window, select Modeling Perspective and click OK.

Adding a diagram view

If a class or freeform diagram is open, skip this step.

In the Model Explorer view, do one of the following:
  • Right-click the model icon and click Add Diagram > Class Diagram
  • Right-click the model icon and click Add Diagram > Freeform Diagram
Add a diagram menu

Now that you know the basic requirements to create a pattern, you are ready to import the sample patterns. You will apply a sample pattern to elements in your new UML model.

You are ready to begin Exercise 2: Importing sample patterns.

Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.