utilization of method graphs to measure cohesion in object oriented software

16
Utilization of Method Graphs to Measure Cohesion in Object Oriented Software Atakan Aral , Tolga Ovatman Istanbul Technical Universtiy Faculty of Computer and Informatics

Upload: atakan-aral

Post on 11-Jun-2015

110 views

Category:

Software


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Atakan Aral, Tolga Ovatman

Istanbul Technical UniverstiyFaculty of Computer and Informatics

Page 2: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Outline

• Introduction

• Motivation

• Contribution

• Method Graphs

• Clustering & Similarity Measurement

• Results & Discussion

• Conclusion

• Future Work

Page 3: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 4: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 5: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 6: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 7: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Method Graphs

• Method Call (MC) relation

– involves method couples that call one another.

Class A{

MA1(){

MA2();

B.MB();

}

MA2(){}

MA3(){

MA4();

}

MA4(){

MA1();

}

}

MB

MA1MA2

MA3

MA4

Page 8: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 9: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Method Graphs

• Internal Call (IC) relation

– involves method couples that call one anotherand are in the same class.

Class A{

MA1(){

MA2();

B.MB();

}

MA2(){}

MA3(){

MA4();

}

MA4(){

MA1();

}

}

MB

MA1MA2

MA3

MA4

Page 10: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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?

Page 11: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Results & Discussion

• 14 most popular open-source Java projects from GitHub and SourceForge

Page 12: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Results & Discussion

Page 13: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Results & Discussion

• Calling two methods, that call each other, from the body of another method, decreases the overall cohesion of software

Page 14: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Conclusion

• We suggest a novel technique that allowsto measure software-wide cohesion.

• It uses static source code analysis.

• Results indicate that its correlation to LCOM HS is 77%.

Page 15: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

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

Page 16: Utilization of Method Graphs to Measure Cohesion in Object Oriented Software

Thank you!