In this tutorial, we will refactor some library classes from a depending project to a library project.
- Start VP-UML.
- Download online_bookstore.vpp and library.vpp that attach with this tutorial. Place them to the same folder.
- Open online_bookstore.vpp by selecting File > Open Project from the main menu. online_bookstore.vpp depends on library.vpp. If you have put both projects in the same folder, you should be able to open online_bookstore.vpp without any difficulties. If you are asked to resolve project dependency, please select library.vpp manually.
- There are two class diagrams in the project. Let's take a look. Open the domain diagram first. Double click on the class diagram domain in Diagram Navigator to open it.

- Study the content. 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 want to refactor the library classes to the lib project.

- Open the Model Explorer.

- The lib package contains the classes we want to refactor. Right click on the lib package and select Refactor to Dependent Project... from the popup menu.

- Click Yes when you are prompted to save project.

- Since the master views of selected classes are owned by the lib diagram, you need to refactor also the lib diagram. An alternative solution is to remove the class shapes from the diagram. But for this tutorial, we just refactor also the diagram. Click Include Diagram(s) to continue.

- Review the elements that will be refactored. If everything is alright, click Continue.

- You are prompted refactor success. You can see that the lib package and the lib diagram do not exist in the online bookstore project. Actually they are moved to the library project. Open the domain diagram.

- We knew that the List class is one of the library classes. The List class you can see on the diagram is actually depending on the List class just refactored. To prove this, try to double click on it. Due to the List class is a dependent element, you can find it not editable.

Resources
- library.vpp
- online_bookstore.vpp
Comments (1)
written by Jessie on December 16, 2011
That takes us up to the next level. Great postnig.