In this wiki page, we will present couple of analysis examples around a case study. In our case, we take ArgoUML, an open-source Java project.
The system contains some deprecated classes.
A typical question is which of these classes we can remove.
Essentially, this boils down to finding the classes annotated with
@Deprecated and then selecting those that are not used anywhere (we ignore reflection for this exercise).
This is an analysis.
We first need to build a model of our system, and for this we will use VerveineJ:
path/to/VerveineJ/verveinej.bat -format json -o ArgoUML-0-34.json -autocp ./libs ./src
You can also download the json file.
The result is that you will get an ArgoUML-0-34/ArgoUML-0-34.json file with the serialized model that can be loaded in Moose. Make sure you have Moose 9.0 or later.
Starting Moose you see the following window:
Click on the MSE button on the top right and load the ArgoUML-0-34.mse file.
An extra step is to point the model to the sources folder. To this end, right-click on the ArgoUML-0-34 model, choose Utilities/Set root folder, and point to the ArgoUML-0-34 folder.
Now we are ready to query our system.
We will first look at deprecated classes. Inspect the model with a right-click on the model and Inspect.
To retrieve the deprecated classes, select the
All model classes entry.
Then, open the script area and type the following script:
self select: [ :each | each isAnnotatedWith: 'Deprecated' ]
Select the script, and execute it with Ctrl + g
In the right pane, you get the list of the deprecated classes in ArgoUML
Just to make sure that we indeed got deprecated classes, let’s investigate one of them and select to view the source code. Select one entity and open the source code browser
Then, by clicking on the Propagate button of the inspector, you’ll get the source code of the selected class in the source code browser.
We now have the 28 classes that are deprecated in our system. Next, we need to check which of those are not used. Or if we think in terms of clients and providers, which of the deprecated classes do not have client classes. Go back to the pane with having 28 classes, open the script area, and execute the following expression:
self select: [ :each | each clientTypes isEmpty]
We get 14 classes that can be removed immediately.
To retrive the other classes, execute the following expression:
self select: [ :each | each clientTypes isNotEmpty ]
This leaves us with 14 classes that cannot be removed because they are still being used.
This wiki page was first created for the moosebook.