A class diagram shows a set of classes, interfaces and their relationships and illustrates the static design view of a system, while a sequence diagram shows the sequence of actions that occurs in a system and illustrates the dynamic view of a system. Within VP products (e.g. VP-UML and Agilian, etc.), you can easily share the models between class diagram and sequence diagram. The changes that made in the sequence diagram can be automatically added to the class diagram as well and vice versa.
- Create a class diagram by one of these 3 methods listed below:
Select File > New Diagram > UML Diagrams > Class Diagram from the main menu.
Select UML > Class Diagram from the toolbar.
Right click on the Class Diagram on the Diagram Navigator and select New Class Diagram from the pop-up menu.
- Draw two classes by selecting the Class icon on the diagram toolbar and clicking it on the diagram. Rename the classes as OrderController and Orderrespectively.
- Create an association link between the two classes by selecting the Association icon on the diagram toolbar and dragging it from OrderController class to the Orderclass.
- Create a sequence diagram by one of these 3 methods listed below:
Select File > New Diagram > UML Diagrams > Sequence Diagram from the main menu.
Select UML > Sequence Diagram from the toolbar.
Right click on the Sequence Diagram on the Diagram Navigator and select New Sequence Diagram from the pop-up menu.
- Drag the OrderController class and Order class from the Diagram Navigator under the Class Diagram tree and drop them on the sequence diagram. Choose Lifeline from the pop-up menu and then Ordercontroller lifeline and Orderlifeline will be created subsequently.
- Add an actor to the sequence diagram by choosing the Actor icon on the diagram toolbar and then click on the diagram. Rename the actor as Clerk.
- Create a message from actor to the lifeline by choosing on the Message icon on the diagram toolbar and dragging it from Clerk actor to Orderlifeline. Repeat the same action for creating a message between OrderController and Order.
- Rename both messages as setOrderNumberby double-clicking on each message.
- To set Call type for a message, move the mouse over the target message, click the Message Type resource icon and select Call > Call from the pop-up menu.
- To select an operation for the Call type message, right click on the message and select Select Operation > Create Operation “setOrderNumber”from the pop-up menu.
- Finally, go back to the class diagram, a new operation, setOrderNumber()is automatically created.