LORE / Teaching / SReMas / Metrics and Visualization Lab Session
During this lab session we use several tools to (i) calculate internal software metrics and (ii) visualize a system's design from the source code to support some of the reengineering patterns from the book Object-Oriented Reengineering Patterns.
- The instructions for the Lab Session.
- The Eclipse 3.x IDE. Installing Eclipse is as easy as extracting the downloaded zip file.
- As a sample system to apply the tools to, you can use Checkstyle, a code style adherence checker application. Alternatively, we encourage you to apply the tools to your student projects.
- For ease of use, we have provided an eclipse workspace containing a precompiled version of Checkstyle for Linux. It is possible to get a build problem
with the ant.jar library.
The easiest solution is to use the one in the eclipse plugins (eclipse/plugins/org.apache.ant_1.7.1v...../lib/ant.jar As an alternative you can also download ant from http://ant.apache.org/bindownload.cgi or you can try to locate an appropriate library on your machine by using the find or locate commands. ("find / - name ant.jar" or "locate ant.jar")
- inFusion is an integrated environment for performing in-depth code and architectural reviews of object-oriented and procedural software systems, written in C, Java or C++. To run it extract the zip file, change to the directory inFusion/tools/inFusion and then run the script infusion.sh (or infusion.bat under windows)(more info) A small description of each of the direct metrics used in the Overview Pyramid can be found on this slide. (Note: We can also use this tool to export the system to an *.mse file, which can then be imported into CodeCity. Remember to choose the FAMIX 2.1 format, otherwise it won't work). There also exists an eclipse plugin of this tool called inCode, which can be downloaded at this site.
- CodeCity is a tool for software analysis. It visualizes a software system as an interactive navigable 3D city. Packages represent districts in the city and classes are the buildings. The class metrics are used for the vsible properties of each building, the heigth represents the number of methods, the width is the number of attributes and the colour the LOC (default settings).
- The Eclipse Metrics Plugin calculates internal software metrics on the source code (Metrics Documentation).
To install this plug-in: Run Eclipse, go to Help menu -> Install New Software ... On the opening dialog press the Add button to add a new Remote Site with the following url http://metrics.sourceforge.net/update. You can then select that url to work with and follow the instructions for installation.
Check the properties of your Java project in the section Metrics, Enable Metrics. Then, click on Window -- Show View -- Metrics -- Metrics View. When you click on the project, a package or a class in the Java or Java Browsing Perspective, the metrics results are shown. You possibly need to rebuild your project in order for the metrics to be calculated.
- Fetch, is our in-house reverse engineering tool chain for C/C++/Java. For this session, we use this version.
- Fetch is a (Unix) command-line tool. The scenarios that Fetch supports are supported by means of shell scripts or shell lines. Therefore, you should use a Unix/Linux/OSX shell environment. Cygwin on Windows only partially works. You can try it but you won't get full functionality. Furthermore, your environments needs a Python >= 2.4, Perl 5 and Java >= 1.5.
- Fetch relies on other programs to carry out particular tasks. It uses Source Navigator (NG) (binaries for Linux/i386) for parsing and Graphviz (in particalar the dot command) to render graph images.
- To get Fetch to work properly, you need to set the variables $SN_HOME, $FETCH, $CROCO and $PMC. $SN_HOME should point to the /bin directory of your Source Navigator installation. Point $FETCH to the root of your Fetch distribution. $CROCO should point to the crocopat binary in $FETCH/bin that matches your platform (processor and operating system). Do the same for $PMC
- First, create a model of a system's source code by using the shell script createEnrichedJavaModel.sh with as single parameter the root directory of the source code. The resulting model is stored in an RSF file (.rsf). Alternatively, use the prepared checkstyle.rsf model.
Further on, look for matching shell scripts in the $FETCH/scripts directory during the exercises and pass on this RSF file as parameter. Fetch generated tables of metrics values, graph images or launches a visualization environment called GUESS depending on the scenario.