Jump to Menu

Move Class to Library Project through Refactoring

Refactoring is the technique of moving project data (i.e. model elements/diagrams) from current project to referenced project to aid in project data sharing among projects. This eases not just the sharing of common project data, but also the improvement of readability as well as the reduction of complexity of project.

Compatible edition(s): Enterprise, Professional, Standard

  • May 3, 2011
  • Views: 27,872
  • PDF

In this tutorial, we will demonstrate the use of the refactoring feature in moving some generic classes to a library project.

  1. Download online_bookstore.vpp and library.vpp and place them in the same folder. You can also download the two files at the bottom of this tutorial, under the Resources section.
  2. Open online_bookstore.vpp in Visual Paradigm by selecting Project > Open from the application toolbar. online_bookstore.vpp references library.vpp. If you have put both projects in the same folder, you should be able to open online_bookstore.vpp without any problems. If you are asked to resolve project referencing, please select library.vpp manually.
  3. There are two class diagrams in the project. Let's open the domain diagram first and take a look. There are several domain classes. OrderList and BookList are subclasses of the List class.
    Domain diagram opened
  4. Open another class diagram named lib. This diagram contains we what called the library classes. The List class, super class of OrderList and BookList, exist also in this diagram. Library classes are classes that are readily be used by other projects due to their generic nature. In this tutorial, we are going to move the library classes to the lib project through refactoring.
    lib diagram opened
  5. Open the Model Explorer by selecting View > Panes > Model Explorer from the application toolbar.
  6. The lib package contains the classes we want to refactor. Right-click on the lib package and select Refactor to Referenced Project... from the popup menu.
    Refactor to referenced project
  7. Projects stored in your workspace will be analyzed for their inter-relationship, to ensure that they will remain intact upon the refactoring of the selected element. Click OK to continue.
  8. Click Yes when you are prompted to to preview the changes to be made in refactoring.
    Preview changes
  9. Review the list of elements that will be moved to the referenced project. Click Continue.
    Refactor elements
  10. Confirm the success message. Then, you can see that the lib package and the lib diagram are no longer under the opening online bookstore project. Instead, they have been moved to the library project. Let's check by opening the domain diagram to take a look. The List class is one of the library classes. The List class on the diagram is actually referencing the List class being moved to the library project. To prove this, double click on the class shape. You should find the shape non-editable, due to its 'reference nature'.
    Non-editable shape



創造美好 共同成長

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

OK