CSE 70, Spring 2010

Software Engineering

Lab Instructions


Measure cyclomatic complexity.

Open IRCMessage.java and examine the parseParams method. Based on reading the code, what is the McCabe Cyclomatic Complexity of parseParams? Write down your answer.

Metrics is an Eclipse plugin that calculates cyclomatic complexity. Follow these directions to install and use it:

  1. Install the plugin.
    1. In Eclipse's Help menu, select Software Updates ...
    2. In the Software Updates and Add-ons dialog, select the Available Software tab and hit Add Site ...
    3. In the Add Site dialog enter the URL http://metrics.sourceforge.net/update/ and hit OK.
    4. In the Software Updates and Add-ons dialog again, check the box next to the plugin name and hit Install ...
    5. In the Install dialog, hit Next, then select I accept the terms of the license agreement and hit Finish.
    6. After the installation finishes, in the Software Updates dialog, hit Yes to restart Eclipse.
  2. Enable and use the plugin.
    1. In the Package Explorer tab, select your project and hit Alt+Enter to bring up the Properties dialog.
    2. Select the Metrics panel, check Enable Metrics, and hit OK.
    3. In the Window menu, select Show View -> Other..., then select Metrics -> Metrics View and hit OK.
    4. In the Java view, notice the Metrics tab in the bottom panel.
  3. Investigate the code.
    1. Look in the Metrics tab. Expand the McCabe Cyclomatic Complexity entry and locate IRCMessage.parseParams. Does the plugin's calculation match your own?
    2. Which methods in the entire project have the most lines of code?
    3. Does the lines of code calculation count comments? Do an experiment to find out.
    4. As you develop your project, use this plugin to measure the complexity of your code to get an idea how many tests you may need and identify opportunities for refactoring.

Valid XHTML 1.0 Strict Valid CSS!