The primarily used technique in measuring cohesion in an object oriented software is analyzing the relations between methods and data members of the software classes. However, extraction of such relations is rather problematic since the usage of data members can vary heavily in program code. Object code analysis is a widely used technique to solve this problem which requires the compilation of the source code. In this paper, we analyze the relations between various method graphs (including call graphs) which can be easily obtained by static source code analysis to obtain software-wide cohesion measures. We perform our analysis to discover the relationship between a widely used cohesion metric, namely LCOM, and the relation among method graphs. This way, we provide cohesion measures that can be extracted rapidly and easily compared to conventional techniques. Proposed measures can be used to obtain information about overall degree of cohesion which in turn can let the designer infer about the quality concerns like modularity and reusability of an object oriented software. Our results show that using different kind of relations in such analysis provides significantly different results in evaluating software-wide average class cohesion. Using graphs involving cooperating methods provide the most correlated results with the LCOM metric.
http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6605841
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Utilization of Method Graphs to Measure Cohesion in Object Oriented Software
1. Utilization of Method Graphs to Measure
Cohesion in Object Oriented Software
Atakan Aral, Tolga Ovatman
Istanbul Technical Universtiy
Faculty of Computer and Informatics
3. Introduction
• Cohesion is the harmony of software
components in performing responsibilities
• Hard to measure quantitatively
• Cohesion of a class is usually measured by
examining common data usage of its methods
4. Motivation
• Conventional techniques analyze object
code and require compilation
• Hard to detect data usage from source code
– Indirect ways to access a variable
• Prevents evaluating incomplete code
• Our aim is to derive a pure source code based
cohesion measure
5. Contribution
Source Code
Parsing
•Abstract Syntax
tree based Java
Parser
Graph
Extraction
•Java Universal
Network/Graph
Graph
Clustering
•Weak Component
Clustering
Similarity
Measurement
•Adjusted Rand
Index
Correlation
Analysis
•Pearson
Correlation
• A cohesion measure that
– depends purely on static analysis
– considers only method-to-method relations
– is graph based and software-wide
– is highly correlated to LCOM metric
6. Method Graphs
• Cooperating Methods (CM) relation
– involves method couples that are called
together from another host method.
Class A{
MA1(){
MA2();
B.MB();
}
MA2(){
B.MB();
MA3();
MA4();
}
MA3(){}
MA4(){}
}
MB
MA1MA2
MA3
MA4
8. Method Graphs
• Method Layout (ML) relation
– involves method couples that are in the same
class.
Class A{
MA1(){}
MA2(){}
MA3(){}
MA4(){}
}
Class B{
MB1(){}
MB2(){}
}
MA1
MA1MA2
MB1
MA4
MB2
9. Method Graphs
• Internal Call (IC) relation
– involves method couples that call one another
and are in the same class.
Class A{
MA1(){
MA2();
B.MB();
}
MA2(){}
MA3(){
MA4();
}
MA4(){
MA1();
}
}
MB
MA1MA2
MA3
MA4
10. Clustering & Similarity
• 4 graphs are clustered using Weak
Component Clustering
• 6 clustering couples are compared using
adjusted Rand index
– CM—MC: Are the methods calling each
other, also called together from another body?
– IC—ML: What is the level of fragmentation
within classes?
11. Results & Discussion
• 14 most popular open-source Java projects
from GitHub and SourceForge
13. Results & Discussion
• Calling two methods, that call each other,
from the body of another method,
decreases the overall cohesion of software
14. Conclusion
• We suggest a novel technique that allows
to measure software-wide cohesion.
• It uses static source code analysis.
• Results indicate that its correlation to
LCOM HS is 77%.
15. Future Work
• to adapt our measure to class level
• to use direction—weight data to improve
accuracy
• to build a mathematical basis for the
relation between our measure and the
LCOM metric
• to study on the other correlated groups