-
Notifications
You must be signed in to change notification settings - Fork 5
How to use the Architecture Evaluation Tool for Java Code
The architecture evaluation tool (AET) was created to measure the complexity, coupling and cohesion of Java code especially of code generators written in Java. As in such applications libraries, frameworks and glue code is used which may temper with the result, we added the ability to define which classes belong to the code to be measured, defining all else as API. Furthermore, in Java classes are used to express behavior, data or both. The AET allows to mark classes as data classes which are then ignored while computing all metrics.
To better understand how to use the AET, we describe its use with a simple application, the single service JPetStore. Please note JPetStore has almost no cohesion as it is a very simple Web application utilizing struts.
- Eclipse Oxygen or newer
- Xtext and Modelling features installed
- GECO installed https://build.se.informatik.uni-kiel.de/eus/geco/snapshot/
- ELK installed http://download.eclipse.org/elk/updates/releases/0.3.0/
- Kieler installed http://rtsys.informatik.uni-kiel.de/~kieler/updatesite/
- Kieler KGraph Editing and Visualization
- Kieler Lightweight Diagrams Runtime
- Kieler Lightweight Generic Diagram Views
- Maybe additi
- AET plugins installed
- Version of AET from our repository https://build.se.informatik.uni-kiel.de/eus/se/snapshot/
- Compiled the plugin yourself, clone the repo with https://github.com/rju/architecture-evaluation-tool.git
- Start Eclipse
- Select Help > *Install New Software ...
- The install dialog opens
- Press the Add... button and enter
- Name: AET
- Location: https://build.se.informatik.uni-kiel.de/eus/se/snapshot/
- Press Add
- Select all features you need, for Java these are
- Core Framework and Metrics
- Java Project Support
- Press Next >
- Follow the instructions and install the extension
In this section, we use JPetStore-6 as an example application. In case you want to use this application too, you can find our version at https://github.com/research-iobserve/jpetstore-6.git
- Clone the example application
git clone https://github.com/research-iobserve/jpetstore-6.git
- Go into the
jpetstore-6
directory and switch to thesingle-jpetstore
branch - Open Eclipse
- Select File > Import...*
- Choose Existing Maven Project from the options
- Press Next >
- Specify the correct path to the jpetstore directory
- Press Finish
Eclipse will now import the project. In case some Eclipse Maven extensions are missing, it will ask to install them. You may choose to do so or might skip this step. Either way some features used in the maven pom.xml
will produce errors, as Eclipse does not understand them. In that case you have to select the issue in the ```pom.xml`` file and choose the ignore option in the editor. After that you might have to:
- Select the jpetstore-6 project, right click on its name and select Maven > Update Project
If everything is setup fine continue with the tutorial.
We need to define which classes belong to the system and which classes are data classes.
Data Classes Create a file in the root directory of the project and call it data-type-pattern.cfg
to identify the data classes. The file content contains one pattern per line. For the JPetStore example we enter the pattern org.mybatis.jpetstore.domain.*
This is sufficient for this project. However, the AET uses Java regex patterns. Therefore, the correct pattern would be org\.mybatis\.jpetstore\.domain\..*
The given pattern selects all classes in org.mybatis.jpetstore.domain.*
to be data classes. They are ignored when calculating the complexity.
System Classes Create a file in the root directory of the project and call it observed-system.cfg
to identify system classes. The file content contains one pattern per line. For the JPetStore example we enter the pattern org.mybatis.jpetstore.*
The given pattern selects all classes in org.mybatis.jpetstore.*
to be part of the observed system, except classes marked as data classes.
- Right click the
jpetstore-6
project and choose Java Analysis. This triggers the analysis. - Two views will pop up.
- The Analysis Log View shows all activities and list all Modules (classes, interfaces), Nodes (methods) and potential warning which may indicate unused code or Java code which is not compatible with the supported versions.
- The Analysis Result View shows results from the measurements taken by the tool. The first column identifies the project, the second the value identifier and the last the value. The following values are returned
- size of the observed system (that is the number of classes) 19
- lines of code 1014
- cyclomatic complexity X : this line can appear multiple times. The X indicates the cyclomatic complexity and the value in behind it the number of occurances of methods with that complexity.
- number of modules (includes system classes and API classes) 52
- number of nodes (for Java this are methods) 189
- number of edges (these are method calls) 203
- hypergraph size 1206.05
- hypergraph complexity 827.73
- inter module coupling 642.16 (complexity of the hypergraph only including inter module edges)
- graph cohesion 0.0022 (where 1 would indicate a fully interconnected graph)
- The Analysis Result View provides three additional functions in the upper right corner of the view
- Data export allows to export the table as CSV
- Graph export allows to export the graph as xmi
- Clear result view
There is also a graph view option, but that seems to be missing from the repository at the moment.