Skip to content

Your first analysis

In this tutorial, we perform a first analysis on a real case study: ArgoUML, an open-source Java project.

The system contains some deprecated classes. A typical question is: which of these classes can we 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).

Before starting, make sure you have installed Moose.

As explained in What is Moose?, we first need a model of the system.

Build the model yourself with VerveineJ

To build the model, we use VerveineJ, the Java parser of Moose. You can use its docker image or install it on your computer:

  1. Download and unzip the latest release of VerveineJ.

  2. Create an ArgoUML-0-34 folder.

  3. Download the ArgoUML version 0.34 sources and place them in the ArgoUML-0-34/src folder.

  4. Download the ArgoUML version 0.34 libraries and place them in the ArgoUML-0-34/libs folder.

  5. From the ArgoUML-0-34 folder, run VerveineJ:

    Terminal window
    path/to/VerveineJ/verveinej.sh -format json -o ArgoUML-0-34.json -autocp ./libs ./src

You get an ArgoUML-0-34/ArgoUML-0-34.json file containing the model of ArgoUML.

  1. In Moose, open the Models browser from the Moose menu.

    Models browser

  2. Click on the JSON button on the top right and select the ArgoUML-0-34.json file.

  3. Moose asks which Famix meta-model the file follows. ArgoUML is a Java project, so select FamixJavaModel.

    Import famix java model

  4. (Optional) To see the source code of the entities, point the model to the sources folder: right-click on the ArgoUML-0-34 model, choose Utilities >> Set root folder, and select the ArgoUML-0-34 folder.

Now we are ready to query our system.

We first look for the deprecated classes. Inspect the model with a right-click on the model and Inspect.

Opening query browser

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.

Show deprecated classes

In the right pane, you get the list of the 28 deprecated classes of ArgoUML.

To make sure that we indeed got deprecated classes, let’s look at the source code of one of them. Select one entity and open the Source code browser (Specialized Browsers >> Famix >> Source code).

Opening source code browser

Then, click on the Propagate button of the inspector: the source code of the selected class appears in the Source code browser.

Propagate to source code browser

We now need to check which of the 28 deprecated classes are not used. In terms of clients and providers: which deprecated classes have no client classes? Go back to the inspector pane listing the 28 classes, open the script area again, and execute:

self select: [ :each | each clientTypes isEmpty ]

We get 14 classes that can be removed immediately.

Request empty clientTypes list

To retrieve the other classes, execute:

self select: [ :each | each clientTypes isNotEmpty ]

This gives 14 classes that cannot be removed because they are still used.

You have performed your first analysis with Moose. Now, analyze your own project.


This tutorial was first written for the Moose book.