Вы находитесь на странице: 1из 5

A Brief Guide in Modeling UML using StarUML

1. Creating a Project When you start StarUML, you will be prompted with a project wizard asking the approach you want to use for your current project. Instead of choosing default approach, we use the Rational Approach (Figure 1). Click OK, and you will soon see the workspace.

Figure 1. Project Wizard You can create a new project by selecting [File] [New Project] or use Ctrl+N.

2. Creating UML Diagrams As you will be soon familiar with the tool, this guideline will focus only on three diagram types, namely use case diagram, class diagram, and sequence diagram. When you selected the Rational Approach, you will see that there are four packages in the Model Explorer (top-right side of the workspace) called Use Case View, Logical View, Component View, and Deployment View. a. Use Case Diagram To draw a use case diagram, double-click the Use Case View. You can start drawing use cases in the default Main diagram or you can add a new diagram by right-clicking the Use Case View and then choose [Add Diagram] [Use Case Diagram]. The diagram notations can bee seen from the Toolbox on the left pane (See Figure 2). Note that the content of the Toolbox changes depending on which diagram type you are currently working on. To draw a diagram element (e.g., a use case), you need to click the diagram element in the Use Case pane (in Toolbox) and click in a desired position in the canvas. Note that you can browse or modify the properties of a diagram element via the Property pane underneath the Model/Diagram Explorer.

Useful Resource: http://staruml.sourceforge.net/docs/user-guide(en)/toc.html

Figure 2. The Toolbox b. Class Diagram To create a class diagram, you can either draw diagram elements in the Main diagram of the Logical View package or create a new class diagram. To create a new class diagram, right-click the Logical View Package and select [Add Diagram] [Class Diagram]. To start creating diagram elements, double-click the desired class diagram in the model explorer. Adding a Class to the Canvas Select element Class in the toolbox (left pane) and click in any position you desire in the canvas. Adding Class Attributes To add an attribute to a class, double-click the class and choose the blue rectangle that appears on the right side of the class.

Figure 3. Adding class attributes Adding Class Operations (Methods) To add an operation to a class, double-click the class and choose the red rectangle that appears on the right side of the class.

Figure 4. Adding class operations Editing/Deleting Class Attributes/Operations To edit or delete class attributes/operations, double-click the attribute or operation you want to modify/delete. You can choose to modify the visibility (left pane of the class) or to add, delete, or reorder the attributes/operations (right pane).

Useful Resource: http://staruml.sourceforge.net/docs/user-guide(en)/toc.html

Figure 5. Modifying class properties

Creating an Association between Classes To create an association, click the association button in the Toolbox. Next, drag from one class and drop to another class to create the association between these two classes. The procedure to create different types of relations between classes (e.g., dependency, inheritance) is similar to this method.

Figure 6. Creating class associations Note that you can modify the attributes of a class, association, or any other diagram elements via the Properties pane (bottom-right of the workspace).

Figure 7. Properties pane

c. Sequence Diagram You can either create a sequence diagram in a new package in the Model Explorer or create it as sub-diagrams of a use case. For now we will use the latter procedure. Useful Resource: http://staruml.sourceforge.net/docs/user-guide(en)/toc.html 3

1. Right-click any use case that you have created and select [Add Diagram] [Sequence Diagram]. 2. You can rename the CollaborationInstanceSet1 with the name of the corresponding use case (e.g., Create patient). 3. You can rename the InteractionInstanceSet1 with type of behavior that the sequence diagram is describing (e.g., basic flow, alternate flow 1). 4. You can also rename the name of the sequence diagram.

Figure 8. Adding a sequence diagram in the model explorer 5. To start adding element to the diagram, double-click the newly created sequence diagram. Adding a New Object of a non-existent class To add a new object in the diagram, click the Object button in the Toolbox and click in any position in the canvas. To add the class of this object to the model, double-click the object and click the class figure in the right pane of the object. Having done this, you will be asked to enter the name of the class; after OK button is clicked, a new class will be created in the Model Explorer.

Figure 9. Adding a class from an object Adding a New Object of an Existing Class To add a new object of existing class, you can simply drag and drop the class to the canvas.

Useful Resource: http://staruml.sourceforge.net/docs/user-guide(en)/toc.html

Adding a Message Call To add a message call from one object to another, select the stimulus button in the Toolbox and drag from the source object to the destined object. Having done this youll see the following:

Figure 10. Assigning a message to an operation of a class You can click the = sign to refer the message to an existing class operation. In this case, youll have to choose one of the class operations.

Figure 11. Selecting the correct operation of a class In case the operation is not yet exist in the class, you can first click the red rectangle on the right side. Next, you will have to specify the operation name and, if necessary, its visibility. Having done this step, the operation will be added to the corresponding class. Note that this procedure will only execute if the class already exists in the model.

Figure 12. Adding new operations from a message 3. Saving a Project To save the project, select [File] [Save] from the menu. Youll be prompted to enter the name of the project and the location to save it. Useful Resource: http://staruml.sourceforge.net/docs/user-guide(en)/toc.html 5

Вам также может понравиться