Detecting bad smells in source code using change history information

Post on 16-Jul-2015

74 views 5 download

Tags:

Transcript of Detecting bad smells in source code using change history information

Detecting Bad Smells in Source Code Using Change

History Information

Pós Graduação em Ciência da ComputaçãoAluno: Carlos Eduardo DantasOrientador: Marcelo Maia

Fábio PolombaGabriele Bavota Automated Software Engineering (ASE)Massimiliano Di Penta 11-15/nov/2013Andrea de Lucia

Detecting Bad Smells in Source Code Using Change History Information

Introduction

• Bad Smells is a symptom of poor design and implementation choices, and makesource code more difficult to maintain;

• Low quality is generally associated withlower productivity, more rework andmore effort for developers.

Detecting Bad Smells in Source Code Using Change History Information

Introduction

• Bad Smells need to be carefully detectedand monitored;

• Refactoring actions should be planned andperformed to deal with them.

Detecting Bad Smells in Source Code Using Change History Information

Introduction

• Approaches to detect bad smells in source code, rely on structural information extracted from source code;

• Ex: DECOR, Jdeodorant,ComplexClass;

• Can´t detect many of the smells described by Fowler, that are intrinsically characterized by how source code changes over time

Detecting Bad Smells in Source Code Using Change History Information

HIST (Historical Informationfor Smell deTection)

• Approach to detect source code smells based on change history information extracted from versioning systems;

• Analyzing co-changes occurring between source code artifacts;

• Detect 5 bad smells from Fowler´s catalog.

Detecting Bad Smells in Source Code Using Change History Information

HIST - Divergent Change

• Class is change in different ways for different reasons

Detecting Bad Smells in Source Code Using Change History Information

HIST - Shotgun Surgery

• Changes in some class triggers many littlechanges to several other classes;

• Detection – at least one method thatchanges with methods present in more than X different classes.

Detecting Bad Smells in Source Code Using Change History Information

HIST – Parallel Inheritance

• Every time you make a subclass of oneclass, you also have to make a subclass ofanother.

Detecting Bad Smells in Source Code Using Change History Information

HIST – Blob

• Class implementing several responsabilities, large number of atributes, operations and dependencies.

Detecting Bad Smells in Source Code Using Change History Information

HIST – Feature Envy

• A method is more interested in a classother than the one it is actually in.

• Detection – methods affected as thoseinvolved in commits with methods ofanother class of the system Y% more thanin commits with methods of their class.

Detecting Bad Smells in Source Code Using Change History Information

HIST (Historical Informationfor Smell deTection)

• Process – Markos European Project

Detecting Bad Smells in Source Code Using Change History Information

Study Design

• Goal: evaluate the effectiveness of HIST;

• RQ1 – How does HIST perform in detecting code smells?

• RQ2 – How does HIST compare to the techniques based on static code analysis?

Detecting Bad Smells in Source Code Using Change History Information

Study Design - Projects

Detecting Bad Smells in Source Code Using Change History Information

Study Design - snapshot

• Split the Project history, running HIST onthe corresponding snapshot;

• Simulating a developer performing code smell detection on an evolving software system;

• Risk to perform code smell detection on a very unstable snapshot, or development motionless.

Detecting Bad Smells in Source Code Using Change History Information

Study Design - Oracle

• Manually build by 2 master´s students, analysing each snapshot’s source code looking for instances of those smells;

• Students were not aware of the experimental goals and of the way that HIST identifies code smells

Detecting Bad Smells in Source Code Using Change History Information

Study Design - metrics

• cor – set of true positive smells (manually identified);

• det – set of code smells detected by HIST.

Detecting Bad Smells in Source Code Using Change History Information

Study Design - metrics

Detecting Bad Smells in Source Code Using Change History Information

Results

Detecting Bad Smells in Source Code Using Change History Information

Results

Detecting Bad Smells in Source Code Using Change History Information

Results

Detecting Bad Smells in Source Code Using Change History Information

Results - Summary

Detecting Bad Smells in Source Code Using Change History Information

Threads to Validity

• Oracle manual analysis could have missed some smells, or else identified some false positives;

• Define alternative static detection techniques em 3 bad smells, that may or may not be the most suitable ones among those based solely on structural information.

Detecting Bad Smells in Source Code Using Change History Information

Conclusion

• HIST clearly outperforms static code analysis;

• HIST highlight smells that are subject to frequent changes;

• HIST requires sufficient amount ofhistorical information to infer usefulassociation rules.

Detecting Bad Smells in Source Code Using Change History Information

Questions and future research

• Can we define a hybrid approach to detectsmells ?

• Does a class affected by a smell representa problem even if it does not change sooften?

• Does HIST have applicability on othertypes of smells?