When you start a new diagram with the UML Model Diagram template, Visio Professional 2007 displays the Model Explorer window, opens UML stencils for each diagram type, and adds the UML menu, as Figure 20-5 shows.
Follow these steps to create a model for your system:
1. | Choose File, New, Software and Database, UML Model Diagram. |
2. | Choose UML, Models.
|
3. | Click a cell in the Model column, type the name of your model, and then click OK. In the Model Explorer window, Visio Professional 2007 adds the new model and a package. |
4. | |
5. | Select a category, change the properties as appropriate, and then click OK. |
6. | If you want to add an element to the model that doesn’t appear in a diagram, go to the Model Explorer, right-click a package or class, choose New, and then select the element you want to add. |
Note
To add a diagram to the model, right-click a package, class, or use case in the Model Explorer, choose New, and then choose the type of UML diagram you want to add. Or right-click the drawing page for an existing static structure, use case, collaboration, sequence, deployment, or component diagram, and then choose Insert UML Diagram on the shortcut menu.
Use case diagrams portray an interaction between a user and a system and represent one image of a system’s functionality that is triggered by user actions. You usually create use case diagrams in the early stages of development and refine them in later stages. A use case diagram typically depicts an overarching set of events that complete a process rather than an individual step or transaction. The use case diagram consists of the users (actor shapes), the system (the System Boundary shape), and the use cases themselves, as Figure 20-6 shows.
The relationships among actors and use cases are represented by one of the following connectors:
Communicates Use this shape between actor and use case shapes to show that an actor participates in a use case.
Extends Use this shape between use case shapes to extend the behavior of a use case to another. For example, connect the Extends shape between use case A and use case B to show that an instance of B includes the behavior of A.
Uses Use this shape between use case shapes to show that the behavior of one use case uses the behavior of the other. For example, connect the Uses shape between use case A and use case B to show that an instance of A includes the behavior of B.
Follow these steps to create a use case diagram:
1. | In the Model Explorer, right-click the package or subsystem in which you want to add a use case diagram, and then choose New, Use Case Diagram. |
2. | Drag the System Boundary shape from the UML Use Case stencil onto the drawing page. |
3. | Drag the Use Case shape from the stencil and place it inside the system boundary. Repeat for each use case. |
4. | Drag the Actor shape from the stencil and place it outside the system boundary. Repeat for each user or outside influence that interacts with the system. |
5. | Double-click a use case shape to display the UML Use Case Properties dialog box. |
6. | |
7. | Drag Communicates shapes from the stencil, and then connect them between use case and actor shapes. |
8. | Drag Uses and Extends shapes from the stencil, and then connect them between use case shapes. |
9. | To define element properties, double-click a shape to open its UML Properties dialog box, and then define the property values you want. |
Note
The System Boundary shape does not have properties.
Class diagrams show the static structure of a model by describing the types of objects in a system and the relationships that exist among them. In a class diagram, you can specify attributes, associations, operations, methods, interfaces, and dependencies, as Figure 20-7 shows. If you create a class diagram with objects and no classes, the diagram is referred to as an object or conceptual static structure diagram. A conceptual diagram is a snapshot of a class diagram that shows instances of objects and data values and so is useful for providing examples of data structures. However, conceptual diagrams are not as common as class diagrams.
Follow these steps to create a static structure diagram:
Sequence diagrams show the actors or objects participating in an interaction and the events they generate arranged in a time sequence. As Figure 20-8 shows, the goal of the diagram is to express interactions. Because sequence diagrams show the explicit sequence of messages, they are well-suited for representing real-time specifications and other complex scenarios.
Follow these steps to create a sequence diagram:
Activity diagrams portray the internal behavior of a method for a specific class or use case and represent a flow driven by internally generated actions. A type of statechart, an activity diagram shows all the states as action states, as Figure 20-9 shows. The flow of control is triggered by the completion of actions in the source state. Activity diagrams encourage you to notice and document parallel and concurrent activities. This makes them excellent tools for modeling work flow, analyzing use cases, and dealing with multithreaded applications.
Inside Out: Distinguishing between activity and statechart diagramsAn activity diagram is really just a variation of a state machine. When you want to show a flow that is driven by internally generated actions, create an activity diagram. When you want to represent a flow in response to external events, create a statechart diagram. |
Follow these steps to create an activity diagram:
Statecharts show the sequence of states an object goes through during its life. A state machine, which is attached to a class or use case, is a graph of states and transitions that describes the response of an object to outside stimuli. A statechart diagram represents a state machine. By documenting events and transitions, a statechart diagram shows the sequence of states an object goes through during its life, as Figure 20-10 shows. In contrast, an activity diagram represents a flow driven by internally generated actions.
Follow these steps to create a statechart diagram:
You can create a collaboration diagram to describe the context in which certain behavior occurs, such as to clarify a use case or operation. A collaboration diagram shows an interaction among a group of objects—that is, their collaboration—as the connecting lines between classifier role shapes. Within an interaction, the objects collaborate by exchanging messages, which appear as the text above the association role connectors. The arrows on a connector point toward the recipient of the message, as Figure 20-11 shows. Unlike a sequence diagram, a collaboration diagram does not imply sequence in the way messages are depicted, and so messages are numbered to show their sending order.
Follow these steps to create a collaboration diagram:
1. | In the Model Explorer, right-click the package in which you want to add a collaboration diagram, and then choose New, Collaboration Diagram. |
2. | |
3. | Double-click the Classifier Role shape to display the UML Classifier Role Properties dialog box. |
4. | In the Name box, type a name for the classifier role. Define other properties as desired, and then click OK. |
5. | For each set of objects you want to represent, drag a Multi-Object shape onto the drawing page. To name the object, double-click the shape to display the UML Classifier Role Properties dialog box, and then type the name. Define other properties as desired, and then click OK. |
6. | To indicate links between the objects, connect Association Role shapes to the objects. |
7. | Double-click each Association Role shape to open the UML Association Role Properties dialog box, in which you can add a name, message flow, message label, multiplicity, and other property values. Then click OK. |
Component diagrams represent implementation decisions and show dependencies among components, such as source code files, binary code files, executable files, or dynamic-link libraries (DLLs), as Figure 20-12 shows. Typically, each component in a component diagram is documented in more detail in a use case or class diagram.
Follow these steps to create a component diagram:
1. | In the Model Explorer, right-click the package or subsystem in which you want to add a component diagram, and then choose New, Component Diagram. |
2. | Drag a Component shape from the UML Component stencil onto the drawing page for each component you want to represent. |
3. | Where appropriate, drag an Interface shape onto the drawing page and glue the endpoint without the circle to a component shape. |
4. | Use Dependency shapes to indicate the relationships between components or between one component and another component’s interface. |
5. | Double-click each shape to open its UML Properties dialog box, in which you can add a name, attributes, operations, and other property values depending on the type of shape. Then click OK. |
Like component diagrams, deployment diagrams represent system implementation. A deployment diagram symbolizes the structure of the run-time system and communicates the configuration and deployment of the hardware and software elements that make up an application. Deployment diagrams consist of nodes, components, and the relationships between them, as Figure 20-13 shows. A node is a run-time physical object that represents a processing resource, which can include both human resources and mechanical processing resources.
Follow these steps to create a deployment diagram:
1. | In the Model Explorer, right-click the package or subsystem in which you want to add a deployment diagram, and then choose New, Deployment Diagram. |
2. | Drag a Node shape from the UML Deployment stencil onto the drawing page. Drag Component and Object shapes into the node. Drag a selection handle on the node to resize it. Repeat to add all the nodes you need. |
3. | Where appropriate, drag an Interface shape onto the drawing page and glue the endpoint without the circle to a component shape. |
4. | Glue Communicates shapes between nodes to indicate the relationships between nodes. |
5. | Glue Dependency shapes between components and objects or between components and other components’ interfaces. |
6. | Double-click each shape to open its UML Properties dialog box, in which you can add a name, attributes, operations, and other property values depending on the type of shape. Then click OK. |