THE SCENT OF DESIGN SMELLSSHOULD DEVELOPERS CARE ABOUT IT?
Foutse Khomh
Associate Professor and FRQ/IVADO Research Chairfoutse.khomh@polymtl.ca@SWATLabDESIGN DECAY
Adding newfeatures!
Bugfixing!

Poor designChoices!
(anti-patterns)

WHAT ARE DESIGN SMELLS?

“Symptoms of poor design and implementation choices”[Fowler, 1999]

DESIGN SMELLS➡ Long Method➡ Large Class➡ Divergent Change➡ Shotgun Surgery

BLOB (GOD CLASS)▪ Symptoms:▪ Large controller class▪ Many fields and methods with alow cohesion*▪ Lack of OO design.
▪ Procedural-stylethanobject

oriented architectures.
*How closely the methods are related to the instance variables in the class.
Measure: LCOM (Lack of cohesion metric)

BLOB (GOD CLASS)

SPECULATIVE GENERALITY

The code is created “just in case” to support anticipated future features that never get implemented

ANTIPATTERNS AND CODE SMELLSCONJECTURED TO…
Impact program comprehension, software
evolution and maintenance activities

WHAT WE DIDHOW WE THOUGHT ABOUT IT

Source Coderepositories

Source control
CVS/SVN/Git

INVESTIGATING CHANGE-PRONENESS(IEEE TCSE MIP Paper)

RELATION BETWEEN CODE SMELLS ANDCHANGE-PRONENESSINVESTIGATING FAULT-PRONENESS(The EMSE Paper)

RELATION BETWEEN ANTIPATTERNSAND FAULT-PRONENESSANTIPATTERNS AND FAULT-PRONENESSEclipse

231814950

Odds Ratio

Odds Ratio

ArgoUML

0.10.1 0.14 0.18.1 0.22
Releases

432101.00.26

3.0.1 3.2.1
Releases

3.3.1

Rhino

Mylyn
40

Odds Ratio30

Odds Ratio

2.1.2

23158030
201001.0.1

2..0M1Releases

2.0M31.4.R3

1.5R3

1.5R5 1.6R3Releases

1.6R6

Antipatternclasses have up
to 30 times morechances toexhibit faults
Especially true forcoupling-related
antipatterns(e.g., MessageChains)

FAULT-PRONENESS: WHAT ANTIPATTERNS?
ArgoUML

Especially true
for couplingrelated
antipatterns(e.g., MessageChains)

Eclipse

Mylyn

Rhino

AntiSingleton
Blob
CDSBP
ComplexClass
LargeClass
LazyClass
LongMethod
LPL
MessageChain
RPB
0%

25%

50%75%100%

125%

M. Diantipattern
Penta% of releases where thesignificantly correlates with fault pronenessINVESTIGATING ENERGY-EFFICIENCY(The TSE Paper)

ANTIPATTERNS AND ENERGY-EFFICIENCYENERGY MEASUREMENTENERGY MEASUREMENTBlob (BL)
Lazy Class (LC)Long-parameter list (LP)
Refused Bequest (RB)Speculative Generality (SG)Binding Resources too early (BE)HashMap usage (HMU)
Private getters and setters (PGS)ANTIPATTERNS AND ENERGY EFFICIENCY
Removing
Binding resources
too early, Privategetters andsetters, Refused
Bequest, andLazy Class antipatterns canimprove energy
efficiency

DO THEY REALLY
SMELL THATBAD?

DESIGN FLAWS CORRELATE WITH
SOFTWARE DEFECTS INTRODUCTIONSMELLS LIKE TEEN SPIRIT…

Smell intensity more
important than othermetrics for predicting
fault-pronenessDEFECT-PRONENESS

DO THEY REALLY
SMELL THATBAD?
YES, BUT…

CODE SMELL DIFFUSENESS
Coupling-related code smells are generally poorly diffused

13%of the considered releases
contained a Message
Chains instanceLONGITUDINAL ANALYSIS
Without Smell
With Smell

God ClassMessage Chains
Without Smell
With Smell

Long Parameter List
Without Smell
With Smell

WHAT ABOUT THE MAGNITUDE
OF THE EFFECT?

SMALL EFFECT,REFACTORING MIGHT BE WORTHLESSCODE SMELLS ARE DISCONNECTEDFROM ARCHITECTURAL PROBLEMS
Smells not reflected inarchitectural problems
Architectural problems notdiscovered by smelldetectors

SMELLS ARE EFFICIENT WAYS TOORGANIZE THE SOURCE CODE…
Junior developers performbetter when working withsource code with a centralized
control styleSMELLS DO NOT INCREASE
MAINTENANCE EFFORTON THE LIFE AND DEATH
OF CODE SMELLSWHEN BLOBS ARE INTRODUCED
Commits required to a class for becoming smell
0255075100

WHEN BLOBS ARE INTRODUCED
Commits required to a class for becoming smell
0255075100

SMELL REMOVAL
Code Removal

40%

Code Replacement

33%

Code Insertion

15%Refactoring

9%

Major Restructuring

4%0%

10%

20%

30%

40%50%

CONFIRMED BY A RECENT STUDY
THROUGH INTERVIEWS

…SO DEVELOPERS FOCUS ON OTHER
THINGS WHILE DOING REFACTORING…

BEYOND CODE SMELLS…

SQL SMELLS
Tool for detecting query antipatterns from Bill Karwins SQL
Antipatterns catalog

CODE SMELLS IN MODEL-VIEW
CONTROLLER ARCHITECURESSERVICE ORIENTED ARCHITECTURE
SMELLS

ENERGY SMELLSANTIPATTERNS AND SMELLS IN MULTILANGUAGE SYSTEMS
Forthcoming @EuroPLOP’19, CASCON’19, TPLOPTAKEAWAYS - SMELLS
Bad practices in (software) development are everywhere, beyond
source code

TAKE AWAYS - GENERAL
The magnitude of a phenomenon might change based on the angle
from which one observes it

CONCLUSION