In this tutorial, we will demonstrate the use of the refactoring feature in moving some generic classes to a library project.
- 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.
- 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.
- 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.
- 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.
- Open the Model Explorer by selecting View > Panes > Model Explorer from the application toolbar.
- 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.
- 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.
- Click Yes when you are prompted to to preview the changes to be made in refactoring.
- Review the list of elements that will be moved to the referenced project. Click Continue.
- 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'.