How to Draw UML Sequence Diagram?

March 16, 2016 Views: 6,839 PDF Link

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.


  1. Download Simple-Registration.vpp. You can also find this file at the bottom of this tutorial.
  2. Open the downloaded .vpp file in Visual Paradigm. To open a project, select Project > Open from the application toolbar.
  3. Open the class diagram Registration. Study the diagram content. We have three classes - RegistrationUI, RegistrationController and User.
    UML class diagram
  4. Now, we want to model the interaction between object instances of these classes in runtime. Since the controller class is responsible to control 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.
    New sub-diagram from class
  5. In the New Diagram window, select Sequence Diagram and click Next. Keep the diagram name as provided and click OK to confirm.
    Select sequence diagram
  6. This creates an empty UML sequence diagram. Select Boundary LifeLine (B) from the diagram toolbar.
    Select lifeline
  7. Click on the diagram to create a boundary lifeline.
    Boundary lifeline created
  8. Enter registrationUI as the name of lifelife and then press Enter to confirm.
    Lifeline named
  9. Right click on the lifeline and select Select Class > Select Class... from the popup menu.
    Select class for lifeline
  10. In the Select Class window, select the RegistrationUI class and then click OK to confirm.
    Select class
    After that, the lifeline will look like the following.
    Class selected
  11. Create a Control LifeLine registrationController : RegistrationController and an Entity LifeLine user : User. Don't forget to select the appropriate classes for them. The diagram will look like the following.
    Three lifelines created
  12. Let's model the method invocations between lifelines. Move the mouse pointer over lifeline registrationUI.
    Mouse over lifeline
  13. Press on the Resource Catalog resource and drag it out.
    Create message
  14. Move to lifeline registrationController and release the mouse button.
    To release mouse button
  15. Select Message from Resource Catalog.
    Select message in Resource Catalog
  16. This pops up a list of name that you can choose for the new sequence message. You can see that those are operation of classRegistrationController. Select createUser(name, password).
    Operation selection
  17. 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.
    Mouse over activation
  18. Press on the resource Resource Catalog and drag it out.
  19. Release the mouse button on the lifeline user.
  20. Select Create Message from Resource Catalog.
    Create create message
    Create message is created. Your diagram should look like this:
    Create message created
  21. Create messages setName and setPassword from lifeline registrationController to user. Up to now, the diagram becomes:
    Sequence messages created
  22. You can also specify the arguments of operations. Take the message createUser(name, password) as example. Right click on it and select Open Specification... from the popup menu.
    Opening message specification
  23. Edit the action type property by clicking on the button with dotted caption, next to Action type.
    Edit action type
  24. In the Call Action Specification window, click Add > Text... to add an argument. In this example, click Add > Text... to add argument peter. Click Add > Text... 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 two operations defined).
    Arguments defined
  25. Click OK to close the windows and go back to diagram. The arguments are added and presented on diagram. Finally the diagram become:
    Final UML sequence diagram

Resources

  1. Simple-Registration.vpp

Related Links

  1. More UML sequence diagram toolset
  2. Full set of UML tools and UML diagrams

You may be interested in

  1. Data Flow Diagram (DFD) Tutorial
  2. Writing Effective Use Case
  3. Drawing Entity Relationship Diagram (ERD)
    Tagged:
  4. Data Flow Diagram with Examples - Food Ordering System
  5. Perform UML Modeling in NetBeans
Tags of this article:

Comments (0)

Write comment

Rating

Comment

Enter the calculation result

security code