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.

June 14, 2010
User Rating: / 22
Views: 37,675
PDF Link Add comments
Edition: Community or above (Edition comparison)

  1. Download the project file Simple-Registration.vpp attached with this tutorial.
  2. Start Visual Paradigm in a new workspace.
  3. Open Simple-Registration.vpp and open class diagram Registration. Study the diagram content. We have three classes - RegistrationUI, RegistrationController and User.
    class diagram
  4. 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.
    add sub sequence diagram
  5. In the New Diagram window, choose Suggested > Sequence Diagram.
    add sub sequence diagram
  6. 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.
    open model explorer
  7. 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.
    drag to diagram
  8. Select Lifeline in the popup menu. If you select Class, it will create class shapes in sequence diagram.
    create lifelines
    By selecting Lifeline, lifelines will be created, with the three classes set as classifiers.
    rearranged
  9. Let's model the method invocations between lifelines. Move the mouse pointer over lifeline registrationUI.
    move pointer to lifeline
  10. Press on the resource icon Message -> Message.
    select message resource
  11. Move to lifeline registrationController and release the mouse button.
    drag to controller
  12. 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).
    select oper
  13. 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.
    move pointer activation
  14. Select the resource icon Create Message -> Lifeline.
    create message
  15. Move to lifeline user and release the mouse button.
    create message created
  16. Create messages setName and setPassword from lifeline registrationController to user. Up to now, the diagram become:
    messanges created
  17. 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.
    show params
    The parameters are then presented.
    has params
  18. 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.
    open messeage spec
  19. Edit the action type property by clicking on the button with dotted caption, next to Action type.
    edit action type
  20. 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).
    argus specified
  21. Click OK to close the dialog boxes and go back to diagram. The arguments are added and presented on diagram. Finally the diagram become:
    end result

Resources

  1. Simple-Registration.vpp

Rate this Article

Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).

You may be interested in

  1. Data Flow Diagram (DFD) Tutorial
  2. Writing Effective Use Case
  3. Share Design, Discuss Design with PostMania
    Tagged:
  4. Draw Entity Relationship Diagram (ERD)
    Tagged:
  5. How to Organize Diagrams with Package
    Tagged:
Tags of this article:

Comments (16)

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.

written by Gibson Doepoh on October 26, 2012

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.

written by Gibson Doepoh on October 26, 2012

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.

Thanks

written by Jick Yeung (VP) on October 26, 2012

Hi Gibson,

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.

written by Gibson Doepoh on October 28, 2012

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.

written by Gibson Doepoh on October 28, 2012

// 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.

written by Jick Yeung (VP) on October 29, 2012

Hi Gibson,

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.

Write comment

Rating

Comment

Enter the calculation result

security code