uma análise da associação de co-ocorrência de anomalias de código com métricas estruturais

Post on 16-Apr-2017

45 Views

Category:

Software

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

“An analysis of the co-occurrence association code

anomalies with structural metrics”

Carlos E. C. Dantas, Marcelo de A. Maia (FACOM – UFU) [2016]

IV Workshop on Software Visualization, Evolution and Maintenance (VEM)

VII Brazilian Conference on Software: Theory and Practice (CBSOFT)

carloseduardodantas@iftm.edu.br

marcelo.maia@ufu.br

1/20

OUTLINE

1 - Introduction.

2 - Study Design

2.1 - Data Extraction

2.2 - Data Analysis

3 - Results

4 – Conclusions

5 - Future Work

2/20

1 - INTRODUCTION

Code Bad Smells (Code Anomalies) – poor design and implementation choices

3/20

1 - INTRODUCTION

• Several Code Anomalies tended to be present in the same class

4/20

org.apache.tools.ant.RuntimeConfigurable.java

Long Method Complex Class Long Parameter List

1 - INTRODUCTION

• But..• Many studies focussed only on individual effects of each Code Anomalie

• Some studies identified inter-relations of Code Anomalies

5/20

2 – STUDY DESIGN

• Goals:

• Discover the most common co-ocurrence between 12 anomalies in 5 open-source Systems.

• Measure the effects of the co-ocurrunces using coupling and cohesion metrics in affected and non affected classes.

6/20

2 – STUDY DESIGN2.1 – Data Extraction

7/20

DatabaseAnt

JHotDrawLog4j

Lucene-SolrTomcat

Git LogCommits

Decor

COPE

2 – STUDY DESIGN2.1 – Data Extraction

8/20

2 – STUDY DESIGN2.1 – Data Extraction

9/20

Code Anomalie Affected Classes

Long Method 5763

Lazy Class 2721

Complex Class 2507

Long Parameter List 2044

Anti Singleton 765

Class Data Should Be Private 609

Spaghetti Code 110

Refused Parent Bequest 86

Large Class 71

Base Class Should Be Abstract 49

Speculative Generality 21

Many Field Attributes 18

2 – STUDY DESIGN2.1 – Data Analysis

•Discover the most frequent co-ocurrences•Association Rules with APRIORI algorithm

•3% support and 80% confidence

10/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: org.apache.tools.ant.RuntimeConfigurable.java• Long Parameter List since first version.

• Method maybeConfigure() growth with many conditions.

11/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: org.apache.log4j.joran.action.ParamAction.java• Long Methods with many parameters like begin() using global static variables.

12/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: org.apache.log4j.pattern.PatternParser.java• Using global static variables like globalRulesRegistry

• Method parse() growth with many conditions.

13/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: org.apache.ant.core.execution.ExecutionFrame.java• Complex Class since first version

• Some methods like fillinDependencyOrder() had growth, and Long Method smell appear.

14/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: javax.servlet.http.HttpUtils.java• Static methods without attributes – Lazy Class since first version

• Method parseName() growth (Long Method), with many conditions (Complex Class).

15/20

3 – RESULTS3.1 - Execution of APRIORI algorithm

Example: org.apache.lucene.queryParser.ParseException.java• Many public attributes – Class Data Should Be Private since first version

• Method getMessage() broken encapsulation, many conditions using public fields (Complex Class).

16/20

3 – RESULTS3.1 – Structural Metrics

15,45 91,9

841,32

9,853,87 29,01 52,71 4,430

100

200

300

400

500

600

700

800

900

CBO RFC LCOM Ca

Coupling and cohesion Metrics

With Long Method Without Long Method

17/20

3 – RESULTS3.1 – Structural Metrics

63,23%

45,03%

0,00%

10,00%

20,00%

30,00%

40,00%

50,00%

60,00%

70,00%

Presence of other Code Anomalies

With Long Method Without Long Method

18/20

4 – CONCLUSIONS

• Strong co-ocurrences between some anomalies.

• Long Method is a key anomalie, influences Coupling and Cohesion metrics.

19/20

5 – FUTURE WORK

• Recommend refactoring oportunities in these relations;

• Discover new co-ocurrences in more anomalies.

20/20

top related