textual analysis for code smell detection
TRANSCRIPT
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
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]
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
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
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
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]
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
S U M M A R I Z I N GTACO - Textual Analysis for Code Smell Detection
Textual Analysis is useful for
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 …
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