Part 3 - Building a Model
Now that we have a new model created and loaded into the workspace (from Part 2), our new goal is to add some content to the model.
There are many ways to add content, but for this first example we will take a convenient shortcut and add model content using a model pattern. To do this you will:
- Select an appropriate Perspective
- Select a model pattern
- Familiarize yourself with the pattern content
- Add the pattern content to your repository
- Find the new content in the Project Browser and explore any new diagrams
So let's get started ...
Selecting a Perspective
As we mentioned earlier, a Perspective is a constraint placed on the workspace to only show a limited set of Technologies. We can select a Perspective in a number of ways, but for this walk through we will use the drop menu in the top right of the user interface. Our goal will be to create a simple Use Case model that we can later extend and customize.
Once you have found the Perspective menu, click on it and select 'UML | All UML' as shown here.
Using a Pattern
Doing this will cause the Model Wizard to appear in the central design area, pre-set to show all the UML Model Patterns (and there are quite a few!) Scroll down until you find the 'Use Case' section and select the 'Basic Use Case Model'. You should now be looking at something resembling this image:
Note that the right hand side has some very useful information about the pattern, including an image to show what you will get, a discussion of when you should use this pattern, additional references and other material. While some of the terms and references might be unfamiliar at this stage, it would be a good idea to do a quick read through to become familiar with what we are adding to the new model.
When you have finished reading, click on thelocated in the lower left corner of the Model Wizard. Enterprise Architect will now create new model elements, diagrams and Packages as required to make a copy of this pattern for you to customize and play with.
Lets look at the Project Browser
Ok, now that we have created our first model content, let's take a look at what we have added. To do this, take a look at the Project Browser.
As you can see from this image, there is new content that has been added to the model. This includes a top level Package and diagram, and some Actors and Use cases (within the 'Actors' and 'Use Cases' Packages). Let's take a look at this in detail.
Double-click on the 'Basic Use Case Model' diagram link to show the graphical view of what we have. You should see this diagram:
In this diagram you can see several Actors and Use Cases. If you click on one of the Actors and then press, or right-click and choose 'Find | In Project Browser' from the context menu, the 'Actors' Package is expanded and the element selected in the diagram will be selected in the Project Browser, as shown here.
As you can see, there is an underlying model-level element in the Project Browser that has a graphical representation in a diagram. Note that you can place a single model element in as many diagrams as you like, and that changing the name or notes or other element properties will be reflected immediately in all diagrams in which the element has been placed.
Working with Properties
Let's take a closer look at one of the elements and see what kind of information you can add to describe in detail what a particular element's purpose and behavior can be.
There are many property windows in Enterprise Architect, and for this walk-through we will look at a few of the most important. There are many shortcuts and keystrokes to bring up different property sheets, but for now it is simplest to access them from the main Ribbon:
Start > Explore >
The Properties Window
Let's start with a look at the main Properties window. Select the 'Properties' item from the 'Start > Explore > Properties' ribbon menu.
As you select items on the diagram or in the Project Browser, you can see the Properties window change to reflect the appropriate settings and current content for the current selection. If you click on an Actor, you will see the Actor's name and many other settings. If you select a relationship between a Use Case and an Actor, you will see the Properties window change to reflect this new type of thing (connector). If you click on blank space on the diagram, the diagram itself will become the current selection and the appropriate properties will be available in the Properties window.
Note that when you select an element in a diagram and then switch to the same element in the Project Browser, the properties do not change as the two visual elements are actually representations of the same single element.
You can change some element properties by editing the selected item in the Properties window. Try changing an Actor's name, Alias, Keywords or Status.
The Notes Window
A second very important window to become familiar with is the Notes window. This window is where you will type your descriptive text about an element's purpose and any other relevant information necessary to fully and completely describe that element. This is one of the most important windows because when it comes to other people reading and understanding your model, the Notes and descriptive text are one of the major determinants of how useful and expressive your model actually is.
Select the 'Notes' item from the 'Start | Properties' ribbon menu.
(Shortcut key is)
Try entering some notes for different elements.
The Responsibilities / Scenarios Window
Another major window you should learn to use is the Responsibilities window. This is a collection of three other windows, each one of which provides important modeling detail.
You can access the three Responsibility windows from the ribbon: 'Start | Explore | Properties'.
In the drop list select: 'Requirements' or 'Constraints' or 'Scenarios'.
Lets look at each in detail:
- Firstly there is the Requirements window. This window lets you add Requirements for an element that represent responsibilities that particular element must satisfy. These are sometimes referred to as 'Internal Requirements' to distinguish them from the more general System Requirements that can involve multiple elements.
- Secondly there is the Constraints window. This window lets you enter restrictions and constraints on an element's behavior, capability or structure. Many advanced behavioral models use the Constraints window to specify, in detail, how a system will function.
- The third tab is the Scenarios window. This window lets you either enter simple text or use the Structured Scenario editor to build detailed descriptions of how an element will behave in a certain situation. Scenarios are most frequently used with Use Cases, but can be used with any element type where appropriate, to explain some aspect of model behavior.
There are many (many) more property windows in Enterprise Architect that are used to describe and edit element specifications. We have seen a few of these now, and as you become more familiar with the tool, you should experiment with others as the occasion arises.
In general, pressingwhile the focus is in a Properties window will activate the Help for that window and you can read about the window's purpose and general usage.
Working with Diagrams
Diagrams are the visual representation of the model and provide one or more windows into the model's structure and behavior. Learning to work with diagrams is an essential part of modeling with Enterprise Architect. We will look at some of the most fundamental aspects of using diagrams to view and build models.
Open a Diagram
If you want to view or work with an existing diagram, you can open it by double-clicking on its icon in the Project Browser. For this short introduction, you should locate the Basic Use Case Model diagram we created earlier and double-click on its icon to open it. If it is already open it will be selected and become the focus window.
Selecting and moving elements
Now that we have our diagram open, try clicking on elements to select them. Once selected you can click and drag to move, right-click to select actions from a context menu, observe or work with an element's properties in the various property windows and/or modify an element's appearance and other visual characteristics. Note that you can also click on connecting relationships between elements and likewise edit and view properties, appearance and positioning.
The Layout Ribbon
The third Ribbon category is 'Layout' and it is the main ribbon category devoted to manipulating the appearance of diagrams. There are commands to change diagram themes, set element appearance, align and format elements, layout diagrams and filter diagram content. Many of these tools are described in detail in the Help, so take the time to read up on the tools and actions available so you can make the most of your diagrams.
Adding a Scenario diagram to a Use Case
Now that we have some familiarity with diagrams, let's add a new one and build up a simple Sequence diagram indicating the flow of actions and responses between an Actor and a Use Case. First we will need to select a Use Case in the Project Browser that will contain the new Sequence diagram (or Interaction).
Create the Diagram
To begin with, click on 'Use Case A' in the Project Browser to select it. Now, right-click on it to display a context menu and select 'Add | Interaction | with Sequence Diagram'. Give the new Interaction a name and click on the .
You should now have something similar to this image in your Project Browser.
Note that there is a new Interaction container with an empty Sequence diagram. Double-click on the Sequence diagram icon to make it the new default workspace. Now you will have a blank diagram workspace and the Toolbox will have changed to show elements commonly used in Sequence diagrams. Firstly though, we will make use of our model and place a link to the relevant Actor onto our diagram.
In our original diagram, Use Case A had a relationship to Actor A, so let's find Actor A in the Project Browser and drag and drop it onto the new diagram.
In the dialog that pops up, select 'Link' as the type of placement required and click on the OK button.
A new visual representation of Actor A is now created and placed onto the Sequence diagram as a Lifeline.
Next, we need to add a Boundary element to represent the system being modeled and how it will interact with our Actor. From the toolbox, click on theand then click to the right of the Actor lifeline. You should now have a diagram that resembles this image:
OK - we now have an Actor and a System and we want to represent the flow of Action and Response between the two entities. We can model this using messages between the two.
Click back on the Actor Lifeline and look for the Quicklink button - this is a small 'up arrow' located just at the right edge of the selected element, and is only visible when the element is selected.
Now, click-and-hold on the Quicklink button, then drag across to the System Lifeline and release. This creates a new message in our model, between Actor A and System. Select the new message on the diagram and note that the Properties window switches to 'Connector Properties', allowing you to edit details of the new connector. After entering a few details for the message and clicking the , your diagram workspace should resemble this image:
A return message can be created in similar fashion, by clicking on System, then dragging its Quicklink button across to the Actor A Lifeline. Select the new message on the diagram and fill in the details in the Connector Properties window. In the 'Control Flow Type' section of the Properties window, select the option 'Is Return'. Your diagram should now display the return message, similar to this image:
Building the Model
1. Basic Skills
The Design Ribbon
The Design ribbon groups together commands that are used for creating and modifying model items, such as elements, diagrams and Packages.
It provides access to a number of windows, such as the Properties window, Features window and Responsibilities window, as well as commands for viewing Package content and diagram content as lists or Gantt charts.
Take a few moments now to explore the different menus and sub-menus presented by the Design ribbon.
We will now use the Design ribbon to perform some basic modeling tasks, such as creating a new Package and creating a new diagram within the Package, before creating some new elements and connectors on the diagram. In this example, we will create a simple Class model.
Create a Package
We will create a new Package under the Model root node, so click on the Model root node in the Project Browser then, from the Design ribbon's 'Package' panel, choose 'Insert > Insert a Simple Package'. The 'New Package' dialog will open. Here, you can enter a name for your new Package and you can choose to create a Package only, create a Package with a diagram, or choose a model pattern to insert into the new Package.
For this walk-through, choose 'Package Only', enter a name for the Package, such as 'My Class Model', then click on the. You should see the new Package in the Project Browser, as a child of the Model root node.
Create a Diagram
Now, we will create a Class diagram within the new Package.
Click on the Package in the Project Browser then, from the Design ribbon's 'Diagram' panel, choose 'Insert'. The 'New Diagram' dialog will appear.
The default name for a diagram is the same name as its parent Package; leave this as it is.
In the 'Type' section, select from 'UML Structural', and choose the diagram type 'Class'. Click on the OK button.
The new Class diagram will appear in the Project Browser and it will open in the main diagram workspace.
The Diagram Toolbox provides a palette of elements and connectors that can be selected and dropped onto the currently open diagram. Doing so creates a new element or connector of the selected type within your model and displays it on the diagram where you dropped it. The Toolbox displays a set of elements and connectors that are commonly used with the current diagram type and this set changes as you open diagrams of different types.
Open the Diagram Toolbox now by clicking the 'Toolbox' button in the 'Diagram' panel of the Design ribbon. The Toolbox is displayed on the left side of the diagram workspace.
This image shows the new, empty Class diagram and, beside it, the Diagram Toolbox showing the elements and connectors appropriate for working with Class diagrams.
Add elements to the diagram
Let's now use the Diagram Toolbox to add some elements to our Class diagram.
Select the Class element in the Toolbox, then click on the empty diagram. A new Class named 'Class1' is created in your model and placed onto the open diagram. The Class name 'Class1' is applied by default. You can type a new name into the Class on the diagram, or you can change the name later using the element Properties window. Create a second Class on the diagram by again selecting 'Class' in the toolbox and dragging it onto the diagram.
Your workspace should now resemble this image:
To create a relationship between two elements on a diagram, simply select a relationship type in the Diagram Toolbox, then drag a line from one element on the diagram to another. Most relationships are directional, so dragging a link from Class1 to Class2 is different to dragging a link from Class2 to Class1.
Click on the Generalize relationship in the Diagram Toolbox then, on the diagram, drag a line from Class2 to Class1.
The relationship that is created indicates that Class1 is a generalization of Class2.
Add Elements Using Quicklinker
We briefly looked at the Quicklinker in Working with Diagrams, where we created links between two elements in the form of Interaction messages. Now we are going to use the Quicklinker to create a new element at the same time as creating a new relationship from an existing element.
In the diagram 'My Class Model', click on Class1 to select it. The Quicklinker arrow should be visible beside the top-right corner of Class1. Click and drag the Quicklinker arrow to the right, releasing the mouse button in empty space on the diagram. This action displays a pop-up menu that prompts you to choose a relationship type, then an element type. From the menu, choose 'Realization | Interface'.
The resulting connector and element are shown here:
2. Using Perspectives and Model Patterns
Enterprise Architect offers a wide range of different Perspectives that cater to the many different kinds of modeling you can perform. As mentioned earlier, a Perspective is a constraint placed upon the user interface to only show a particular technology or set of technologies. It is used to reduce complexity and help you focus on your task.
Add a Requirements Model
We will now build a simple Requirements Model in our project. Firstly, let's select one of the Requirements Perspectives. From the Perspectives menu, choose 'Requirements | Requirements'.
After selecting the Requirements Perspective, the Model Wizard is displayed in the main workspace area, offering just a selection of basic Requirements model patterns. Firstly, we should choose where in the model, this new content will be added. Click on the folder icon beside the 'Add To:' field at the bottom of the Model Wizard page, then choose the Model root node and click on the OK button. Now, let's select the pattern 'Two Level Requirement Hierarchy' and click on the .
The selected model pattern is added to our model under the Model root node.
Double-click on the diagram link in the Project Browser to open the diagram in the main diagram workspace. You can then select elements on the diagram (or in the Project Browser) and use the element Properties window to tailor them to your own use, by renaming them, entering descriptions in the Notes window or setting other properties as required.
Add a Class Model
We will now add a simple Class Model to our project, following a procedure similar to the one we have just used.
From the Perspectives menu, choose 'UML | Structural'.
The Model Wizard is displayed, showing the Structural Perspective. Scroll through the list to find the Class diagrams, then click on 'Basic Class Diagram with Operations'. Click the folder icon beside the 'Add To:' field and choose the Model root node as the location in which to add the new model content. Finally, click on the Create Pattern button to add the new model content to your project.
The selected model pattern is added to your project; the Packages, diagram and elements are shown in the Project Browser.
Double-click on the diagram link 'Basic Class Diagram with Operation' in the Project Browser. This opens the diagram in the main workspace. Now, we will use the Features window to view the operations of Class A.
From the 'Explore' panel of the Start ribbon, choose the menu item 'Properties > Features'. The Features window is displayed; select the 'Operations' tab of this window.
Now click on Class A in the diagram (or in the Project Browser). You will notice that as soon as Class A is selected, the details of its operations are displayed in the Features window. Here you can modify an existing operation, by changing its name, its return type or even its parameter list. When you select an operation in this list, the Properties window switches to Operation Properties, and displays details of the selected operation.
You can also use the Features window to define new operations, by simply typing a name into the list where it says "New Operation...".
This image shows the Features window when Class A is selected on the diagram and the Operation Properties window when Operation B is selected in the Features window.
We have walked you through some simple modeling operations to give you a basic understanding of how you might use Perspectives and Model Patterns to create model structures that you can use as a starting point for creating your own models.
We have also demonstrated using the Project Browser to navigate through the model, using the Diagram Toolbox to add new content to your model via the diagram and using various Properties windows to inspect and modify the properties of various model elements.