SystemAnalyzer allows a user to specify a directory containing all of the source for a Java system, S. It loads the source for this application, creating a class-level dependency graph as it goes. This graph is passed to each member in a list of metric components. Each metric component computes some metric for the dependency graph and returns the result as a string. The string is passed back to the controller, which displays the string.
Test your application by creating metrics for the following:
DIT(S), NOC(S), CBO(S), MHF(S), MIF(S)
You can find code to test your system analyzer in:
Hint: You should be able to do most of this using reflection. The only problem is that reflection can't tell you about the types of local variables. To get this information you must use a parser.
One suggestion is to develop SystemAnalyzer as a plug-in to Eclipse's Java Development Tools (JDT). JDT has an easy-to-use parser that produces objects that instantiate Eclipse's AST (Abstract Syntax Tree) class. In fact, in Chapter 27 of the book "Java Developer's Guide to Eclipse" the authors develop a metrics plug-in. The documentation and source for this code can be found at:
Another suggestion is to use a parser generator such as javacc or Antlr
See JavaGrammars for a 1.1 parser I generated from javacc.