Laurie Williams, Dright Ho, and Sarah Heckman.
[Contact Authors] |
| 1.0 | Introduction to Software Metrics |
| 2.0 | Installing Metrics Plug-in |
| 3.0 | Viewing Metrics |
| 4.0 | Discussion of Metrics |
| 5.0 | Interpretation of Metrics |
| 6.0 | Dependency Graph View |
| 7.0 | Exercise |
| 8.0 | Resources |
Software metrics are used to give programmers feedback about their program. Metrics can be used as guidelines for when to refactor. They provide a way to measure the progress of code during development. In this tutorial, we are going to use Metrics, an open-source Eclipse plug-in, to gather metrics on a project. The plug-in should already be installed into Eclipse for you, but if it is not, installation instructions are provided for you in Section 2. Metrics version 1.3.6 requires Eclipse 3.1. |
To install Metrics, you will need to create a new Eclipse update site. 2.1 Find the URL of the update site for the plug-in: http://metrics.sourceforge.net/update. 2.2 Create an update site for the plug-in.
|
To view metrics on a project, first open up the Metrics view by selecting Window > Show View > Other.... Open up the Metrics tab and select Metrics. In order to display metrics about a project you must enable the project to calculate metrics. Make sure you are in the Java Perspective and have your project open in the Package Explorer. Right click on a project and select Properties. Select Metrics on the left side, and check the Enable Metrics checkbox. Rebuild the project by selecting Project > Build Project (make sure you have the project that you want to build selected in Package Explorer.) If you have Build Automatically enabled, you will not be able to build your project in this manner. Just change a file and save. The project will be rebuilt for you, and the metrics will be calculated. The metrics will be displayed in the Metrics view. There are 23 metrics that are displayed in the metrics view, and they are discussed in section 4 . If the metric is out of optimal range, then the metric is highlighted in red. Otherwise the metric is highlighted in blue if they are in range, and black if the metric cannot be calculated. Each metric has a plus box beside it that expands so that you can study the metrics on all source folders, packages and, where applicable, on class files and methods. Below are some of the metrics for the Coffee Maker example.
|
The metrics information given below was obtained directly from the Metrics plugin website: http://metrics.sourceforge.net/. The author of the metrics plug-in used "Object-Oriented Metrics, measures of Complexity" by Brian Henderson-Sellers and "OO Design Quality Metrics, An Analysis of Dependencies" by Robert C. Martin to obtain the definitions of the metrics used for this plug-in.
|
The safe range for each metric can be changed in the Window > Preferences menu. However, some safe ranges of metrics are provided for you.
|
The Metrics plugin also has a dependency graph view that allows you to see the dependency connections among various packages and classes in your project. To open the dependency graph, click the 5th red/gray square button in the upper right hand corner of the Metrics view (hover over the buttons until the tooltip tells you that the button opens the dependency graph.) The dependency graph allows you to see all the connections between various parts of your project. However, dependency graphs for small projects like CoffeeMaker are boring since the project is so small, but dependency graphs for a large project like Monopoly can be very interesting.
|
| Download the CoffeeMaker example or open the CoffeeMaker example that you used in earlier tutorials, and run the metrics calculations on the project. Show your TA. |