CS 160 Homework #4

Fall 2006

Cay S. Horstmann

The Assignment

In this assignment, you will practice using tools for code review, OO metrics, and coverage testing.

You will run these tools on your team's code. For some of the assignments, it helps if you have an easy way of identifying which class is owned by which team member. In order to make this easy, your project should use package names such as edu.sjsu.cs160.session.alpha5.

Part 1. Code Review

You will use Checkstyle 4.2.

Run CheckStyle on all of the source code of your project. Supply a configuration file that is based on either the Sun or the SJSU coding conventions, whichever your team is actually following.

Answer these questions in a file answers.html.

a) What are the ten files with the most errors, and how many errors does each of them have?

b) Why does the file with the most errors have so many problems? Are there changes that could reasonably be made to the measurement procedure to get a more useful metric?

c) What are the ten most common errors, and how often do they occur?

d) How did you obtain the information for a) and c) from the raw Checkstyle output?

Part 2. OO Metrics

You will use JavaNCSS and ckjm. Have your Ant script run NCSS on all of the source code your project. Produce an output in HTML format: output/javancss_metrics.html.

Then have your Ant script run ckjm on all class (!) files. Produce an output in HTML format: output/ckjm.html.

NOTE: Have the tools produce XML, then use the XSL transforms and the style tasks, following the examples in the documentation. You can do this even if you have no clue what XML or XSL are.

Answer these questions in a file answers.html.

a) What is the total number of non-commented source lines in the source, broken down by team member?

b) Look at a method with a high cyclomatic complexity number. Explain why or why not the high CCN indicates a potential concern with the maintainability of this method. (You may want to look at the explanation of the metric in the textbook and in the JavaNCSS web page.)

c) Look at the ckjm WMC, DIT, NOC, CBO, RFC, and NPM values for a nontrivial class of your choice. Manually recompute these values (showing your work) and comment on any discrepancies. See http://www.spinellis.gr/sw/ckjm/doc/metric.html for the definitions.

Part 3. Coverage Testing

You will use EMMA. Download the latest release version (not the testing version). Have your Ant script measure the coverage of your (not your entire team's) unit tests. Specifically, do this:

Answer these questions in a file answers.html.

a) Looking at the coverage breakdown, which classes are best covered by the tests? Why is coverage better than for the other classes?

b) Which classes show particularly low coverage? Is this a concern? Why or why not?

Your Daily Progress Report

An important part of your homework is your daily progress report.

For each day in which you worked on this homework, add one line to the report.html file. Use this format:

2005-09-03 Installed GridWorld and Ant 3 hours
2005-09-04 Studied Ant. Wrote Ant script to compile the framework 2 hours
. . .
TOTAL x hours

Simply add one line when you are done with a day's work.

Note that you need to keep TWO reports, one for your homework #4 and one for your project. 

Deliverables

For simplicity, assume that JUnit is on the class path. You should assume that the grader has installed Checkstyle, JavaNCSS, cjkm, and EMMA into convenient locations and is using a build.properties file with exactly these entries:

checkstyle.version=4.2
checkstyle.dir=.../checkstyle-${checkstyle.version}
javancss.version=28.49
javancss.dir=.../javancss${javancss.version}
ckjm.version=1.7
ckjm.dir=.../ckjm-${ckjm.version}
emma.version=2.0.5312
emma.dir=.../emma-${emma.version}

Naturally, you should reference these entries in your Ant script and not hardwire any of your local tool locations.