textual analysis for code smell detection

24
Textual Analysis for Code Smell Detection FABIO PALOMBA, UNIVERSITY OF SALERNO DIBT.UNIMOL.IT/FPALOMBA ICSE 2015 SRC MAY 22, 2015 FLORENCE, ITALY

Upload: fabio-palomba

Post on 17-Jul-2015

127 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Textual Analysis for Code Smell Detection

Textual Analysis for Code Smell Detection

FA B I O PA L O M B A , U N I V E R S I T Y O F S A L E R N OD I B T. U N I M O L . I T / F PA L O M B A

I C S E 2 0 1 5 S R CM AY 2 2 , 2 0 1 5

F L O R E N C E , I TA LY

Page 2: Textual Analysis for Code Smell Detection

C O D E S M E L L S A R E S Y M P T O M S O F P O O R

D E S I G N O R I M P L E M E N TAT I O N C H O I S E S

Code Smell

[Martin Fowler]

Page 3: Textual Analysis for Code Smell Detection

C O D E S M E L L S A R E M O R E C H A N G E - A N D FA U LT-P R O N E N E S S

C O D E S M E L L S I N C R E A S E S M A I N T E N A N C E C O S T S

Khomh et. al - EMSE 2012

Banker et. al - Communications of the ACM 1993

C O D E S M E L L S H I N D E R

C O M P R E H E N S I B I L I T YAbbes et. al - CSMR 2011

Page 4: Textual Analysis for Code Smell Detection

S E V E R A L A P P R OAC H E S H AV E B E E N P R O P O S E D, E X P L O I T I N G D I F F E R E N T K I N D O F I N F O R M AT I O N

S T R U C T U R A L I N F O R M AT I O N

H I S T O R I C A L A N A LY S I S

Page 5: Textual Analysis for Code Smell Detection

I S I T P O S S I B L E T O D E T E C T S M E L L S U S I N G C O N C E P T U A L I N F O R M AT I O N?The Third Dimension

Page 6: Textual Analysis for Code Smell Detection

T H E C A S E O F L O N G M E T H O D D E T E C T I O NTACO - Textual Analysis for Code Smell Detection

“A Long Method as a method in which there is the implementation of a main functionality together with auxiliary functions that should

be managed in different methods.”

[Martin Fowler]

Page 7: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell DetectionT H E C A S E O F L O N G M E T H O D D E T E C T I O N

method mi

Page 8: Textual Analysis for Code Smell Detection

method mi

method blocks

extract blocks

T H E C A S E O F L O N G M E T H O D D E T E C T I O NTACO - Textual Analysis for Code Smell Detection

Page 9: Textual Analysis for Code Smell Detection

method blocks

pruned method blocks

extract identifiers

extract comments

extract blocks

T H E C A S E O F L O N G M E T H O D D E T E C T I O NTACO - Textual Analysis for Code Smell Detection

method mi

Page 10: Textual Analysis for Code Smell Detection

similarity matrix

method blocks

pruned method blocks

compute similarity

extract identifiers

extract comments

extract blocks

T H E C A S E O F L O N G M E T H O D D E T E C T I O NTACO - Textual Analysis for Code Smell Detection

method mi

Page 11: Textual Analysis for Code Smell Detection

similarity matrix

method blocks

pruned method blocks

compute similarity

extract identifiers

extract comments

I F E X I S T B L O C K S W I T H S I M I L A R I T Y < T H E N A L O N G M E T H O D I S D E T E C T E D

extract blocks

t

T H E C A S E O F L O N G M E T H O D D E T E C T I O NTACO - Textual Analysis for Code Smell Detection

method m

Page 12: Textual Analysis for Code Smell Detection

T H E C A S E O F L O N G M E T H O D D E T E C T I O N - C A S E S T U D YTACO - Textual Analysis for Code Smell Detection

Apache Cassandra

Apache Xerces

Eclipse Core

Page 13: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Apache Cassandra

Apache Xerces

Eclipse Core

Precision

Recall

F-Measure

T H E C A S E O F L O N G M E T H O D D E T E C T I O N - C A S E S T U D Y

Page 14: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Apache Cassandra

Apache Xerces

Eclipse Core

Precision

Recall

F-Measure

Compared with DECOR approach

[Moha et al.]

T H E C A S E O F L O N G M E T H O D D E T E C T I O N - C A S E S T U D Y

Page 15: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Apache Cassandra

Apache Xerces

Eclipse Core

Precision

Recall

F-Measure

Compared with DECOR approach

[Moha et al.]

T H E C A S E O F L O N G M E T H O D D E T E C T I O N - C A S E S T U D Y

63%51%

DECOR

TACO

OVERALL F-MEASURE

OVERALL F-MEASURE

Page 16: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Apache Cassandra

Apache Xerces

Eclipse Core

Precision

Recall

F-Measure

Compared with DECOR approach

[Moha et al.]

TACO is highly complementary with

respect to DECOR on 2 systems analyzed

T H E C A S E O F L O N G M E T H O D D E T E C T I O N - C A S E S T U D Y

63%51%

DECOR

TACO

OVERALL F-MEASURE

OVERALL F-MEASURE

Page 17: Textual Analysis for Code Smell Detection

A P R AT I C A L E X A M P L ETACO - Textual Analysis for Code Smell Detection

Method: findTypesAndPackages()

Goal: Discover the classes and the packages of a given project

Class: CompletionEngine - Eclipse Core

Page 18: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Method: findTypesAndPackages()

Goal: Discover the classes and the packages of a given project

This method has 65 lines of code

Class: CompletionEngine - Eclipse Core

A P R AT I C A L E X A M P L E

Page 19: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Method: findTypesAndPackages()

Goal: Discover the classes and the packages of a given project

This method has 65 lines of code

A S TAT I C A P P R O A C H C A N N O T

D E T E C T A L O N G M E T H O D

Class: CompletionEngine - Eclipse Core

A P R AT I C A L E X A M P L E

Page 20: Textual Analysis for Code Smell Detection

TACO - Textual Analysis for Code Smell Detection

Class: CompletionEngine - Eclipse Core

Method: findTypesAndPackages()

Goal: Discover the classes and the packages of a given project

This method has 65 lines of code

A S TAT I C A P P R O A C H C A N N O T

D E T E C T A L O N G M E T H O D

But the method manages more than one responsibility

I T A C T U A L LY I S A L O N G M E T H O D !

A P R AT I C A L E X A M P L E

Page 21: Textual Analysis for Code Smell Detection

I S I T P O S S I B L E T O D E T E C T S M E L L S U S I N G C O N C E P T U A L I N F O R M AT I O N !The Third Dimension

YES, IT IS

Page 22: Textual Analysis for Code Smell Detection

S U M M A R I Z I N GTACO - Textual Analysis for Code Smell Detection

Textual Analysis is useful for

smell detection

Page 23: Textual Analysis for Code Smell Detection

Textual Analysis is useful for

smell detection

Is TACO suitable for detecting other smells?

TACO - Textual Analysis for Code Smell Detection

What about a hybrid technique for

detecting smells?

C O M I N G S O O N …

Page 24: Textual Analysis for Code Smell Detection

Textual Analysis for Code Smell Detection

FA B I O PA L O M B A , U N I V E R S I T Y O F S A L E R N OD I B T. U N I M O L . I T / F PA L O M B A

I C S E 2 0 1 5 S R CM AY 2 2 , 2 0 1 5

F L O R E N C E , I TA LY