METRIC ATTITUDE PLUG-IN FOR ECLIPSE USER GUIDE · The Eclipse IDE uses the Java environment, ......
Transcript of METRIC ATTITUDE PLUG-IN FOR ECLIPSE USER GUIDE · The Eclipse IDE uses the Java environment, ......
Metric Attitude Pag. 0
METRIC ATTITUDE PLUG-IN FOR ECLIPSE USER GUIDE
Metric Attitude Pag. 1
CONTENTS
CONTENTS .................................................................................................... 1
INTRODUCTION .............................................................................................. 2
ECLIPSE ........................................................................................................ 2
1. INSTALLING ECLIPS FOR WINDOWS SYSTEM ................................................. 3
2. INSTALLING METRIC ATTITUDE .................................................................. 3
3. METRIC ATTITUDE .................................................................................. 9
4. METRIC ATTITUDE’S FEATURE AND METRICS ............................................. 10
4.1 Feature “Legend” .......................................................................... 10
4.2 Feature “Filter” ............................................................................. 12
4.3 Feature “Layout” ........................................................................... 14
4.4 Feature “Paint” ............................................................................. 19
5. EXAMPLE OF USE METRIC ATTITUDE ............................................................ 21
6. IDENTIFICATION AND REPRESENTATION OF BUG ............................................ 26
Metric Attitude Pag. 2
INTRODUCTION
This manual provides system requirements and instructions for installing Metric Attitude tool.
Metric Attitude is a visualization tool for the reverse engineering of Object Oriented Software.
The goal of our proposal is to ease both the comprehension of a subject system and the
identification of fault-prone classes with the help of a graphical representation..
The tool is implemented as an Eclipse plug-in and it is written in the Java programming language by Dr.
Michele Risi (University of Salerno) and Dr. Giuseppe Scanniello (University of Basilicata).
Below are listed the steps to install Metric Attitude in the Eclipse Rich Client Platform starting with version
3.7.0.
ECLIPSE
Eclipse is an integrated development environment (IDE), it can be used to develop Java applications, and by
means of various plug-ins, other programming languages including Ada, C, C + +, COBOL, Fortran, Haskell,
Perl, PHP, Python, R, Ruby, Scala, Clojure, Groovy, Android and Scheme.
The Eclipse SDK (which includes the Java development tools) is a free software and open source.
You can download eclipse 3.7.0 and above at the following link: http://www.eclipse.org/downloads/
Metric Attitude Pag. 3
1. INSTALLING ECLIPS FOR WINDOWS SYSTEM
You can download Eclipse software directly and freely from to following link:
http://www.eclipse.org/downloads/.
Extract the archive you just downloaded into the favorite directory
The Eclipse IDE uses the Java environment, usually already present in the distribution of software
downloaded. However, if there is no version 7 of Java, you can download the Italian version of the
runtime environment JRE7 from the site of Java (http://www.java.com/it/download/). A few steps
will be sufficient for installing Java, while at the end of this process you will see a test page to verify
the correct installation.
Enter into the working directory containing the Eclipse environment and run the file eclipse.exe.
Figure 1. Eclipse Interface
2. INSTALLING METRIC ATTITUDE
The plug-in MetricAttitude can be downloaded from the following link:
http://www.dmi.unisa.it/people/risi/www/MetricAttitude.html
Extract the compressed file into the workspace directory. This directory is created directly from
Eclipse during its installation.
When you run the file eclipse.exe you can import the plug-in Metric Attitude .
The command to import a plug-in or any software project within the Eclipse IDE is present in “File”
menu.
Metric Attitude Pag. 4
Figure 2. Import a software project in Eclipse
User can click on Import Existing Projects into Workspace Next
Figure 3. The command to import an existing project in Eclipse
Select the path where the project Metric Attitude is content and then press “Finish” button when
activated
Metric Attitude Pag. 5
Figure 4. Select the project to import
The project or Plug-in imported will appear in “Project Explorer” containing all active projects in
Eclipse.
Figure 5. The project or plug-in successfully imported in Eclipse
Metric Attitude needs some plug-in not present in Eclipse to function correctly. For this reason,
before launching the Metric Attitude system you need to install these plug-in using the following
command Help Install New Software.
Metric Attitude Pag. 6
Figure 6. Installing external libraries in Eclipse system
Figure 7. The window containing libraries and plug-ins to be installed in Eclipse
Install the following plug-in. Ensure that you are connected to the network.
Ecore tool SDK (Incubation)
Graphical Modeling Framework (GMF)
The Eclipse VIsualization Tolkit (ZEST)
After finishing installation, you select the project PLayer present into the window Project Explorer
and launch a new configuration by using command Run Eclipse Application to run it.
Metric Attitude Pag. 7
Figure 8. Run an application directly from Eclipse environment
Before using functionality of Metric Attitude of a particular software system, you have to select
configuration parameters. Select from menu Window Preference, making to appear following
configuration window where you can select the voice Metric Attitude Preferences.
Figure 9. Setting parameters of the plugin Metric Attitude
Insert project data to be analyzed with the plug-in Metric Attitude. In particular, you select path in “Source file directory” by pressing “Browse”. In addition, you can select a report file containing description and location of bugs of system in question. Through the “Browse” button to is possible select the “File Bug” while in the “Bug Label” section you can choose from different software in the report, such as the system software "Eclipse Platform 3.5". Finally, you can select the level of detail
Metric Attitude Pag. 8
which the system Metric Attitude provides a description of operations performed by user. The item “Verbose level” allows to activate this feature. In following figure is selected level “Information” OK
Figure 10. Preferences Metric Attitude
In the windows Metric Attitude Commands, you can create a new project concerning software
project selected, and then analyze it. These operations are carried out respectively when user
clicks button “Create the project” and then “Analyze the project”.
Figure 11. Create a new project and analysis of the selected system
Metric Attitude Pag. 9
The following figure shows an example display of selected system (JHotdraw 5.1) and analyzed.
Figure 12. The system JHotDraw 5.1 in Metric Attitude
3. METRIC ATTITUDE
The interface of Metric Attitude is composed of three main sections:
On the left you can see “Project Explorer”section that will contain the Eclipse project created by
Metric Attitude.
On the right you can see “Metric Attitude” section that will contain the graph of project.
In lower section there are two button “Create the project” e “Analyze the project” that allow
respectively generate and evaluate the project
Figure 13. Il layout di Metric Attitude in Eclipse environment
Metric Attitude Pag. 10
4. METRIC ATTITUDE’S FEATURE AND METRICS
4.1 Feature “Legend”
Click on “Legend” will appear a small legend that describes metrics used. Each software
entity is represented with a node, which is graphically represented whit an ellipse and a rectangle
placed just below.
Figure 14. The legend of the metrics used by Metric Attitude
Metrics
Acronym Description
Weighted Methods per Class (WMC) It is the weighted sum of the methods of a class. The weight of a method is given by a factor of complexity to choice. To grow WMC increases complexity of class and decreases possibility of reuse.
Depth of Inheritance Tree (DIT)
It is the maximum distance of a node (class) from root of tree representing structure inherited.
Number of Children (NOC)
Number of subclasses, children of a super-class. The higher the NOC increases the level of reuse. The higher the NOC increases, the amount of testing required to test each subclass.
Coupling Between Object classes (CBO)
Number of collaborations of a class, or number of other classes to which it is coupled.
Response For a Class (RFC)
The response set of a class is a set of methods that can potentially be executed in response to a message received by an object of that class.
Flow Info (FI) It is computed on fan-in and fan-out as follows:
Metric Attitude Pag. 11
FI= L * (fan-in * fan- out)^2. L is a code size metric. It was used the LOC metric. FI is employed to measure testability. Fan-in measures the number of methods called in a software component. Conversely, fan-out is defined as the number of local flows out of a component.
Number of Message Sends (NMS)
It measures number of messages from a method. This metric is designed to be a unbiased measure of size of a method. The value for a class is achieved by summing the NMS values of all methods in the class.
Number of Methods (NM)
It represents number of method of a class and is used to determine complexity.
Lines Of Code (LOC)
It measure length of a program with number of lines of source code.
Number of Comments (NC)
It represents number of comment lines in body of a class and its methods.
Table 1 describes the graphical representation in Metric Attitude of metrics used and
possible relationships between classes.
Table 1. Graphical representation of the metrics and relationships in Metric Attitude
OO Metriche
WMC (Weighted Methods per Class)
DIT (Depth of Inheritance Tree)
NOC (Number Of Children)
CBO (Coupling Between Object classes)
RFC (Response For a Class)
Size of ellipse
Flatten the ellipse
Color of ellipse border
Thickness of ellipse border
Color of ellipse
Traditional code-size Metric
FI (Flow Info)
NMS (Number of Message Sends)
NM (Number of Methods)
LOC (Lines Of Code)
NC (Number of Comments)
Color of rectangle
Thickness of rectangle border
Color of rectangle border
Height of rectangle
Width of rectangle
Relationship
Gerarchia
Delegazione
Campo di accesso
Delegazione astratta
Delegazione virtuale
Metodo ciclico
Campo di accesso ciclico
Hollow triangle shape
Blue arrowed line
Cyan arrowed line
Orange arrowed line
Green arrowed line
Blue line
Cyan line
The dimension of ellipse denotes WMC. The convention is that the larger the ellipse, the higher the metric value is.
Metric Attitude Pag. 12
We used flattening of ellipse to represent DIT. The more the flattening, the higher the metric value is. The color of border of ellipse is used to denote NOC. The color is between light red and dark red. The higher the metric value, the darker the border is. We used thickness of border of ellipse to represent CBO. The larger the thickness, the higher the metric value is. To avoid loosing information about NOC, a thin border is drawn even if CBO is 0. The color of ellipse denotes RFC. The color ranges between black to white. Dark gray represents a smaller metric measurement than light gray. The color of rectangle denotes FI. Similar to RFC, color ranges between black and white. The lower the metric value, the darker the color is. We used thickness of border of rectangle to represent NMS. The larger the thickness, the higher the metric value is. We used the color of border of rectangle for NM. The color ranges between light and dark red. Light red represents a smaller metric measurement than dark red. The height of rectangle denotes LOC. Convention is that higher the metric value, the more the height of the rectangle is. Width of rectangle is used for NC. The higher the metric value, the more the width is.
Relationships between classes are showed , as shown Table 1, as lines: simple, arrowed, and hollow. These lines can assume different colors. With regard to the instance level relationships, we also considered the thickness of the lines associated. More the thickness, the larger the number of links between a source class to a target one is.
4.2 Feature “Filter”
The plug-in Metric Attitude allows you to graphically view the source code through a series of filters by
clicking icon “Filter” will appear the following image:
Figure 15. Menu to activate the filters in Metric Attitude
Inheritance: It allows you to view class inheritance with hollow triangle shape.
Delegation: It allows you to view relationships delegation (that is realized an object that makes it
accessible operations provided by the base class, delegating from the outside that is, without
inherit them, running to a base class object) by blue arrows, the greater is the thickness and the
higher is the number of links between delegator and delegate class. Shift a mouse to arrow,
Metric Attitude Pag. 13
activates a tooltip that shows the classes involved in the delegation and the number of connections
between them.
Virtual Delegation: It allows you to view relationships on virtual delegation classes that implement
a specified abstract method or interface (this is a kind of inheritance in which the part of the object
that belongs to virtual base class becomes a common base for the direct derived class and any
other class that derives). It is represented as a green arrow, where the thicker and higher is the
number of connections between the entities of the relationship. Moving mouse on arrow is active a
tooltip that shows the classes involved in virtual deletion and the number of connections between
them.
Abstract Delegation: It allows you to view abstract delegations (ie reports on a method that is
declared without implementation) between two classes by an orange arrow . Moving the mouse on
arrow is active a tooltip that shows classes involved in abstract delegation and the number of
connections between them.
Field Access: lets you view the access to instance variables of a class by a cyan arrow . Moving
mouse on arrow is active a tooltip that shows fields access involved and the number of links
between them.
Method Call/Field Access Loop: It allows you to view the method calls through the cyan circles .
Hovering the mouse over circle you activate a tooltip that show the names of methods involved
and the number of links between them.
Interface Classes: lets you see classes interfaces. Hovering the mouse on these classes you
activates a tooltip that shows the name of the interface and which classes implements.
Abstract Classes : It allows you to view the abstract classes. Moving the mouse over an abstract
class you activate a tooltip that shows the name of the abstract class, which class extends and
which is implemented. The following figure shows an example of the abstract class
CompositeFigure, where you see the numerical values of the metrics calculated by Metric Attitude.
Figure 16. Example tooltip of an abstract class
Anonymun Classes: lets you see the anonymous classes (they are a particular type of Java classes
that can be defined within the body of a method, and are unnamed). Moving the mouse on these
Metric Attitude Pag. 14
classes you activate a tooltip that shows all details of anonymous class, as well as numerical values
of the metrics.
Enum Classes: It displays the classes declared as an enumeration. They are represented graphically
by an ellipse and a rectangle placed just below. Moving the mouse on these classes you activate a
tooltip that shows all the details of enumerated class, and the numerical values of the metrics.
Concrete Classes: It displays all concrete classes of the selected system. Concrete classes are
represented graphically by an ellipse and a rectangle placed just below . Color, thickness and
flattening of the two forms represent different metrics. Moving the mouse over the concrete
classes you activate a tooltip that shows the name of the concrete class, and the numerical values
of the metrics.
4.3 Feature “Layout”
Metric Attitude implements different layouts to arrange classes of system.
Pressing the “Layout” the following window appears:
Figure 17. Possible layout algorithms in Metric Attitude
Metric Attitude Pag. 15
Grid Layout: This tool allows a two-dimensional representation of the grid. All classes represented
are arranged in a manner such as to horizontally and vertically the grid.
Figure 18. Grid layout
Shift Diagram Layout: It allows to center the entire diagram to the center of window through a
displacement downwards.
Figure 19. Shift Diagram layout
Metric Attitude Pag. 16
Horizontal Shift Layout: It allows horizontal displacement of diagram.
Figure20. Horizontal Shift layout
Tree Layout: The tree diagram represents the classes of the software system in a hierarchical taking
into account relations displayed.
Figure 21. Tree layout
Metric Attitude Pag. 17
Spring Layout: This type of layout has spiral classes in the diagram. Classes are arranged
considering the location of other classes. Entities connected by relationships are at the center of
window.
Figure 22. Spring layout
Radial Layout: It allows you to have the diagram in order to show the relationships of classes than
a parent class. All entities are arranged along a circumference of radius defined.
Figure 23. Radial layout
Metric Attitude Pag. 18
Horizontal Tree Layout: It allows the representation of a tree diagram showing the hierarchical
structure of the classes and display has horizontally.
Figure 24. Horizontal Tree layout
Composite Layout: It allows arrangement of classes through an algorithm layout compound. In
particular, the diagram is represented by means of layout superposed as Spring and Radial.
Figure 25. Composite layout
Metric Attitude Pag. 19
4.4 Feature “Paint”
Metric Attitude allows the representation of source code in class diagrams, click on “Paint”
following window appears:
Figure 26. Possible representations in Metric Attitude
Class Diagram : They are a type of diagram represented in notation of UML diagrams. These
diagrams allow to describe entity types, with their features and possible relationships between
these types. Moreover, classes of software system are shown with their attributes and methods.
Figure 207. Representation of classes in UML notation
OO Metric: This approach is based on metrics to identify design problems in object-oriented
software, offers a number of benefits, such as reusability, decomposition of problem in question is
easy to understand and aiding of future changes. Complexity metrics displayed by clicking on entity
are as follows: WMC (assigned to category of complexity, estimates number of methods involved in
a class), DIT (belonging to the category of inheritance, represents depth of class in inheritance
hierarchy), NOC (belonging to category of inheritance, represents number of children in a class),
CBO (belonging to category of complexity, it estimates number of objects to which a class is
Metric Attitude Pag. 20
coupled), RFC (belonging to category of complexity, because the greater the number of methods
that can be called by a class and the greater the complexity of the same).
Figure 28. Representation OO Metric
Traditional Code-size Metric : Clicking on entities that are represented by rectangles lets you view
following metrics: FI (assigned to category of complexity takes into account several aspects such as
metric size, number of incoming flows in component number of outgoing flows of component),
NMS, NM (assigned to category of complexity), LOC (belonging to class size, is to count all physical
lines of source code, number of statements, number of blank lines), NC (belonging to class size, is
to count number of comment lines in a class).
Figure 29. Representation Traditional Code-size Metric
OO-Traditional Code-size Metric: It allows the representation of the entities through an ellipse and
a rectangle placed just below and as soon as the user moves with cursor over the object you will
see a small "box" with additional information about object itself, it will check all the metrics: WMC,
DIT , NOC, CBO, RFC, FI, NMS, NM, LOC, NC.
Metric Attitude Pag. 21
Figure 30. Representation OO- Traditional Code-size Metric
5. EXAMPLE OF USE METRIC ATTITUDE
Figure 31. Example 1
Metric Attitude Pag. 22
Layout metric attitude enabled filters – Concrete Class, Inheritance, Delegation
Figure 32. Example 2
Layout subject system enabled filters - Concrete Class, Inheritance, Delegation, Virtual Delegation
Figure 33. Example 3
Metric Attitude Pag. 23
Layout subject system enabled filters – Concrete Class, Abstract Delegation, Field Access, Method
Call/Field Access Loop
Figure 34. Example 4
Layout subject system enabled filters – Abstract Delegation, Interface Classes, Abstract Classes,
Anonymous Classes, Enum Classes, Concrete Classes
Figure 215. Example 5
Metric Attitude Pag. 24
Metric Attitude allows to visualize all the parameters of an entity, such as: name, fields, methods,
and metrics, through a tooltip that action as soon as the mouse pointer is over the object graph
(see Figure 36).
Figure 36. Example 6
Metric Attitude Pag. 25
Metric Attitude allows switch between the graphical notation to the source code written in Java by
clicking on the representation of the classes in the diagram shown. This allows the inspection of
source code from graphical representations of Metric Attitude.
Figure 37. Display of source code from graphical representations
Metric Attitude Pag. 26
6. IDENTIFICATION AND REPRESENTATION OF BUG
Metric Attitude support the identification of classes that potentially contain bugs. In order to highlight the
classes that contain the bug using the "Toggle Bug". In particular, the entities of the system software
analyzed that contain errors present in the selected report configuration phase are highlighted in yellow as
shown in Figure 38.
Figure 38. A view of Eclipse 3.5 framework for the identification of classes of risk bug
As shown in Table 2, a subset of the metrics used by Metric Attitude has been validated empirically on
commercial and open source software systems to determine if they can be used as predictive measures of
bugs. Table 2 shows the results obtained from four different evaluations respect the metrics considered.
For example, WMC with higher values imply a low probability of bugs, while for NOC shows the presence or
less of bugs according to the context defined by the values obtained considering other metrics.
Table 2. Predictive Metrics bug