Develop UML Sequence Diagram with UML Class
When you want to model the structure of a system or an application, you can make use of class diagram. When you want to model the interaction between objects in runtime, with the sequence of method invocation, you can make use of sequence diagram. Class diagram and sequence diagram can be related with each other. While a class in class diagram represents a blueprint of data, a lifeline in sequence diagram represents an instance of such blueprint. In this tutorial, we will start from a simple class diagram, and make use of a sequence diagram to model the dynamic method invocation related to a controller class modeled in class diagram.
- Download the project file Simple-Registration.vpp attached with this tutorial.
- Start VP-UML in a new workspace.
- Open Simple-Registration.vpp and open class diagram Registration. Study the diagram content. We have three classes - RegistrationUI, RegistrationController and User.

- Now, we want to model the interaction between object instances of these classes in runtime. Since the controller class is responsible in controlling the registration process, add a sub-sequence diagram from it. Move the mouse pointer to RegistrationController. Click on the resource icon at the bottom right corner and select Add > Other Diagrams > Sequence Diagram from the popup menu.

- This creates an empty sequence diagram. Open the Model Explorer, which is the tab next to Diagram Navigator. You can see the three classes listed there.

- We want to make use of the classes in creating lifelines in sequence diagram. Select the three classes in Model Explorer and drag them onto the sequence diagram.

-
Select Lifeline in the popup menu. If you select Class, it will create class shapes in sequence diagram.
By selecting Lifeline, lifelines will be created, with the three classes set as classifiers.
- Let's model the method invocations between lifelines. Move the mouse pointer over lifeline registrationUI.

- Press on the resource icon Message -> Message.

- Move to lifeline registrationController and release the mouse button.

- This pops up a list of name that you can choose for the new sequence message. You can see that those are operation of class RegistrationController. Select createUser(name, password).

- Relate lifeline registrationController and user. We say that registrationController creates the user lifeline. Therefore, we need to relate them with a create message. Move the mouse pointer over the activation in lifeline registrationController.

- Select the resource icon Create Message -> Lifeline.

- Move to lifeline user and release the mouse button.

- Create messages setName and setPassword from lifeline registrationController to user. Up to now, the diagram become:

-
The operations' parameters are not presented by default. To show them, right click on the background of diagram and select Presentation Options > Message Display Options > Show Messages Operation Signature from the popup menu.
The parameters are then presented.
- We can specify the arguments as well. Take the message createUser(name, password) as example. Right click on it and select Open Specification... from the popup menu.

- Edit the action type property by clicking on the button with dotted caption, next to Action type.

- In the Call Action Specification dialog box, click Add to add an argument. In this example, click Add to add argument peter. Click Add again to add argument mypwd. Note that the two arguments are actually referring to the two parameters given by the operation. If you add the third argument here, it will be ignored (as there are only 2 operations defined).

- Click OK to close the dialog boxes and go back to diagram. The arguments are added and presented on diagram. Finally the diagram become:

Resources
- Simple-Registration.vpp
Rate this Article
Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).
One Moment Please
Thanks for rating this article.
Comments (10)
written by daniel on June 11, 2010
Hello, first great tutorial.
I have a question, when linking messaged I cant not see the parameter. For example I have createUser(name,password) however I dont see those parameters in the sequence diagram. how can I see the parameters in my sequence diagram.
Thank you for you help
written by Jick @ Visual Paradigm on June 14, 2010
Hi daniel,
That's a good question. We have added more steps (from step 16 onwards) to answer your question. If you have other questions, please feel free to post again.
Best regards,
Jick
written by FuShan on July 6, 2010
Dear Sir/Madam,
I have a question about the parameter. First, I right click the [Calss] and select [Add Template Parameter] and then finish it. later, I may find it is not useful. How can I delete the parameter in the Class diagram?
Thank you in advance
written by Tilly on July 6, 2010
FuShan,
Please find the following link to read how to remove parameter:
http://knowhow.visual-paradigm.com/?p=722
regards
Tilly
written by Maciej on April 8, 2011
Cannot find this option in my version, VP UML 8.0...
written by Jick Yeung on April 11, 2011
Hi Maciej,
Please right click at the background of diagram and select "Presentation Options > Message Display Options > Show Messages Operation Signature" from the popup menu.
Best regards,
Jick Yeung
written by Señor Oz on September 23, 2011
Hello, i can see that when you drag all the three classes, the program automatically assign a boundary lifeline, a control lifeline, and a entity lifeline, that is because the classes define the corresponding stereotype in the class diagram? and, i only can assign only these three kinds of stereotypes? Wath happend if i assig another kind of stereotype? Thanks for the answer.
written by Jick Yeung on September 23, 2011
Dear user,
Thank you for your post. You are correct that the boundary, control and entity lifelines are created due to the fact that the classes were assigned with boundary, control and entity stereotypes. You may assign any stereotypes you like to the lifelines. You may also create your own stereotypes and assign to lifelines. The name of assigned stereotypes will be shown in the lifeline shape.
Please feel free to contact me again if you have any questions.
Best regards,
Jick Yeung
written by Tuan Vu on November 15, 2011
if I download "Simple-Registration.vpp", I have zip file and after dezip, there are no *.vpp file!
written by Jick Yeung on November 15, 2011
Hi Tuan Vu,
Please rename the downloaded file to .vpp and try again.