Download presentation
Published byDaniel Barnett Modified over 9 years ago
1
Software Metric Tools Joel Keyser, Jacob Napp, Carey Norslien, Stephen Owings, Tristan Paynter
2
Overview SLF4J Tool Example Code Code Analyzer Linux Kernel JFreeChart
JUnit SLF4J SourceMonitor JMetric Metrics (Eclipse Plugin) Understand
3
Libraries
4
JUnit Overview Library used for creating, running, and sharing details of tests in Java #1 used open source Java library List of detailed features at
5
JFreeChart Overview Library for creating graphs and other charts in Java applications 4.9/5 Stars on SourceForge download page Easy to work with Highly extensible
7
Linux Kernel Overview Operating system kernel for Linux.
Written in C, supported by GCC. A kernel “manages input/output requests from software, and translates them into data processing instructions for the central processing unit and other electronic components of a computer” (Wikipedia)
8
SLF4J Overview Simple Logging Facade for Java
User can plug in desired logging framework at deployment Research in 2013 sampled 10,000 java projects in GitHub and 30.7% of them used SLF4J.
9
OpenJDK7 Overview Open source implementation of Java Standard Edition
Officially supported by Oracle Aided by community participation
10
Metric Tools
11
Code Analyzer (Desktop App)
12
Code Analyzer Overview
Free software Simple to use Supports C (*.c, *.h) C (*.cpp, *.cc, *.h, *.hh) java (*.java) html (*.html, *.htm) Assembly (*.s, *.asm, *.ia)
13
Code Analyzer Metrics http://www.codeanalyzer.teel.ws/
Total Files (For multiple file metrics) Total Lines Code Lines Comment Lines Whitespace Lines Average Line Length Code Lines/File (For multiple file metrics) Comment Lines/File (For multiple file metrics) Code/Comments Ratio Code/Whitespace Ratio Code/(Comments + Whitespace) Ratio Carey
14
Code Analyzer - jUnit
15
Code Analyzer - JFreeChart
16
Code Analyzer– Linux Kernel
17
SourceMonitor (Desktop App)
Jacob SourceMonitor (Desktop App)
18
SourceMonitor Overview
Simple Software Metrics System Free Fully supports most of the common languages (C++, C, C#, VB.NET, Java, and Delphi) Easy to use Somewhat simplistic Performance issues with large software projects, such as the Linux Kernel.
19
SourceMonitor Metrics
LOC Percentage of Comments = (Lines w/ Comments) / LOC per class Number of Branches per class Max + Average depth per class Max + Average Complexity per class
20
How Complexity is Determined
Determined by the number of execution paths through a function/method. Starts with a base of 1 Add 1 for each branch (if, for, while) Add 1 for each && or || in a logical condition Add 1 for each exit from code (continue, break, throw, etc...)
21
Source Monitor Example – Linux Kernel
Entire Linux Kernel Linux Kernel – arch Carey Linux Kernel – block
23
Joel JMetric (Desktop App)
24
JMetric Overview Software used to measure and display Object-Oriented metrics of other software Specifically for Java Can see the data in charts, tables*, or exported text files Created in 1998 through the Swinburne University of Technology Was last updated in 2000, hence the bugs Fails to analyze most files Various interface bugs
25
JMetric Metrics LOC, # variables, # methods Package Level Class Level
Lack of Cohesion of Methods (LCOM) Class Level Cyclomatic Complexity # Parameters # local variables # if statements
26
Lack of Cohesion of Methods
BHS/CK/default are different ways to measure the same thing: the lack of cohesion per class Low value is good (high cohesion), high value is bad (low cohesion) Calculated by comparing the number of methods that share variables with the number of methods that do not The point is that, ideally, all variables would be used by all methods
27
JMetric – JUnit Package Analysis
28
JMetric – JUnit Class Analysis
29
Metrics (Eclipse Plugin)
Phtephen Metrics (Eclipse Plugin)
30
Metrics Overview Add-in to Eclipse Automatically calculates on build
For metrics that are “bad” Shows resource most responsible Allows easy fixing Integrated directly into IDE
31
Metrics (Plugin) Metrics
Cyclomatic Complexity Nested Block Depth Steve
32
Metrics (Plugin) Metrics
Afferent Coupling Efferent Coupling Depth of Inheritance Tree Tristan
33
Metrics - JFreeChart .equals method = 207 lines of if tests
.refreshTicksVertical = 190 lines of nested statements
34
Metrics - JUnit
35
JFreeChart – Number of Parameters
public LegendItem(String label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint)
36
Understand
37
Understand Overview Static Code Analysis Tool
An IDE more concerned about analyzing a software project, rather than developing a software project. Major Product Features Code Knowledge Metrics & Reports Graphing Standards Testing Dependency Analysis Doesn’t care about “good” or “bad” metrics. Supports over a dozen languages, including C/C++/C# and Java. Three price points Floating License: $1,995 Single Developer License: $995.00 Free Two Week Trial
38
Understand Metrics Around 70 metrics Cyclomatic Complexity
Maximum Nesting Depth Maximum Inheritance Tree
39
Comparison - Results
40
Comparison – SourceMonitor Metrics
Library LOC % Comments % Branches/Class SLF4J 26,538 46.0 11.9 Linux Kernel* 37,608 21.2 19.7 JUnit 677,058 17.4 5 JFreeChart 229,491 49.6 14.9 OpenJDK7 3,254,229 43.0 16.1 * Due to performance issues, only the block folder was analyzed.
41
Comparison – SourceMonitor Metrics
Library Avg Depth/Class Avg Complexity/Class Number of Files SLF4J 1.67 1.66 232 Linux Kernel* 1.53 3.69 75 JUnit 1.45 1,226,755** 8071 JFreeChart 1.96 2.38 653 OpenJDK7 2.54 1,359,640*** 14,152 * Due to performance issues, only the block folder was analyzed. ** Two methods were measured with 1,936,482,677 complexity. ***Avg complexity varied widely.
42
Comparison – Plugin Metrics
Library Cyclomatic Complexity Nested Block Depth Afferent Coupling Efferent Coupling Depth of Inheritance Tree SLF4J 1.46 1.26 2.5 2.75 1.162 Linux Kernel* - JUnit 1.265 1.213 12.18 4.557 1.361 JFreeChart 2.27 1.43 35.28 11.42 1.83 Open JDK7* 2.61 .82179 * Plugin only supports Java. Understand and Excel were used to obtain similar results.
43
Conclusion Metrics tools can be very useful for code analysis
Many different types of metrics tool, some open source other commercial Tristan
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.