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 Visual Paradigm 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 New Diagram... from the popup menu.
- In the New Diagram window, choose Suggested > Sequence Diagram.
- 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:
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.
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
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.
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
Cannot find this option in my version, VP UML 8.0...
Please right click at the background of diagram and select "Presentation Options > Message Display Options > Show Messages Operation Signature" from the popup menu.
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.
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.
if I download "Simple-Registration.vpp", I have zip file and after dezip, there are no *.vpp file!
Hi Tuan Vu,
Please rename the downloaded file to .vpp and try again.
Step 4, does not create Three Class automatically as you stated in Step 5, "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", you had to create those three new classes(boundary, control, entity) manually.
Take note, You can say,"You can see the three classes listed there", they need to be created.
Can you prove that the Three new Classes( boundary, control and entity) were created automatically as per the step in Step 5-6. or they were manually created, notice the icon difference in your classes in figure 5 and 6.
The classes were created for you. Did you try with the project file we provided (step 1)? You can download it at the end of the tutorial. Inside the project you can find the controller, model and entity classes. You do NOT need to create them yourself.
Which version are you using, cause in the Standard Edition(Evaluation version Only) I am not seeing the Three classes icons in the Model Explorer window, thou there visible in the registration diagram display area.
// Not yet implemented, how to you execute "implementation", as regard the three classes in this tutorial, I attempted generating the code in PHP, using the EV edition, all the classed has this message, // Not yet implemented.
please send me detail on tutorial when in I can see classes and it implementatition.
First of all, ALL editions and versions of VP-UML supports showing classes in Model Explorer. Did you set a filter which disallowed the classes to be shown in Model Explorer? If not, please send me your project file and a screenshot to our Ticket System.
About code generation, since the UML class models give just the schema level detail, we are unable to generate the logic inside method body and that's why the method bodies aren't implemented.