Sharing Model between Class Diagram and Sequence Diagram
A class diagram shows a set of classes, interfaces and their relationships and illustrates the static design view of a system. Meanwhile, a sequence diagram shows the sequence of actions that occur in a system and illustrates the dynamic view of a system. Within this software, 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 any of these 3 methods listed below.
Method 1- Creating a class diagram from the menu bar:
On the menu, select
File > New Diagram > UML Diagrams > Class Diagram. A new class diagram will be created.
Method 2 - Creating a class diagram from the toolbar:
Click on the
New Class Diagram button

from the toolbar. A new class diagram will be created.
Method 3 - Creating a class diagram from the Diagram Navigator:
Right click on the Class Diagram from the Diagram Navigator on the left side.
Click on the
Create Class Diagram from the pop-up menu. A new class diagram will be created.
Draw two classes by choosing the
Class icon on the diagram palette, select
Class from the menu, then click anywhere on the diagram. Rename the classes by double-clicking on the newly created classes (For example
OrderController and
Order classes).
Create an association link between the two classes by selecting the
Association icon on the diagram palette, click on the
OrderController class and then drag to the Order class.
Create a sequence diagram by any of these 3 methods listed below.
Method 1- Creating a sequence diagram from the menu bar:
On the menu, select
File > New Diagram > UML Diagrams > Sequence Diagram. A new sequence diagram will be created.
Method 2 - Creating a sequence diagram from the toolbar:
Click on the
New Sequence Diagram button

from the toolbar. A new sequence diagram will be created.
Method 3 - Creating a sequence diagram from the Diagram Navigator:
Right click on the Sequence Diagram from the Diagram Navigator on the left side.
Click on the
Create Sequence Diagram from the pop-up menu. A new sequence diagram will be created.
Drag the
OrderController class and
Order class, from the
Diagram Navigator under the
Class Diagram tree, and drop to the newly created
Sequence Diagram (New
ordercontroller and
order lifelines are automatically created).
Add an actor to the sequence diagram by choosing the
Actor icon on the diagram palette and then click on the diagram. Rename the actor as Clerk by double-clicking on the actor, then press
Ctrl+Enter to finish the operation.
Create a message from actor to the lifeline by choosing on the
Message icon on the diagram palette, click on the actor and drag it to the lifeline. Repeat the same action for creating the message between lifelines.
Rename both messages as
setOrderNumber.
Mouse over the message, click the
Message Type resource and select
Call as the message type.
Right click on the message and select
Select Operation... from the pop-up menu. A
Select Operation dialog box is displayed.
Click on the
Create Operation... button from
Select Operation dialog box to create an operation. A
Operation Specification dialog box is displayed.
Enter
setOrderNumber in the
Name field and then click on the
OK button.
Go back to the Class Diagram, a new operation,
setOrderNumber() is automatically created.
Related Articles
Resources