Lafi2019 Code Smells
Lafi2019 Code Smells
2019 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT)
Abstract— Software evolution is an inevitable need in most of Code (LOC), Coupling Between Object (CBO), Depth of
the modern businesses, software that doesn’t accommodate Inheritance Tree (DIT), with variety of thresholds values to
changes is hard to survive the market needs. Also, software detect code smells in code.
changes can affect the overall design of the software and
sometimes in a corrupting way, affecting the maintainability The Rest of the paper is organized as follows code smells
and evolvability of the software, which introduces technical definition is given in section II, code smells effect on defects
debt that needs to be solved by continuous refactoring and and maintainability is given in section III, code smells
restructuring of software. Code smells are useful indicators to detection mechanisms are discussed in section IV, the
identify the parts of the code to be refactored to improve the conclusion is given in section V.
overall maintainability of the software. We present an
overview of software code smells, detection and analysis
II. BACKGROUND
mechanisms and difficulties. Also, we address the effect of
refactoring on software maintainability and error-proneness of Software development Community is always interested
software. in the quality of the developed software artifacts, from the
beginning of software engineering principles formulation and
Keywords— Code Smells, Refactoring, Design Patterns, the famous critical analysis by Dijkstra for the GOTO
Technical Debt statement [1] and its effect on the overall structure of code,
leading to the creation of an unmaintainable type of software.
I. INTRODUCTION Software engineering established the needed constraints
Software code undergoes many changes after its delivery to create a usable software that is resistant to continuous
for many different reasons, however if these changes weren’t changing. By defining the process of development and the
conducted properly then they’re usually accompanied with needed activities to improve the maintainability of software
deterioration of software quality leading to software that is Code smells term were first coined by Riel [2] and
very hard to maintain and read. Brown et al. [3]. To refer to any symptom for bad designed
Software maintenance activities that cause the parts of code that can cause serious problems while
modification of software product after its delivery can be maintaining the software.
categorized into four types: adaptive, perfective, corrective Fowler et. al. defined the code smells formally as certain
and preventive. structures in the code that suggests (sometimes they scream
Most of these maintenance activities are inevitable for) the possibility and need for refactoring [4].
through the course of software production. However, some Fowler et. al. [4] originally provided a set of most
changes sometimes are accompanied with a decline in common code structures that should be avoided or refactored
quality by introducing problematic design structures and (restructured) if found, they gave informal descriptions of
code smells, which leads to the increase of the technical debt twenty-two code smells and the associated refactoring
and the need for future corrective, preventive maintenance strategies that are needed to eliminate them, those code
activities. smells are language-independent but mostly targets object-
To Avoid that, Code smells must be detected early by oriented paradigm-based languages.
exposing and removing them through refactoring which is Mäntylä et al [5] formulated another definition for code
the process of restructuring the program without changing smells as a term that refers to a somewhat a subjective
the external behavior to eliminate code smells and to make indicator of poor design or coding style in specific parts of
sure that any further development is possible. the code and categorized the 22-code smell into five groups
Many approaches have been proposed for automating the according to each characteristic for better understanding and
process of code smells detection. Some of these approaches evaluation (Table I).
use combination of object-oriented metrics such as Line of
TABLE I. CODE SMELLS TAXONOMY [5] of good quality (i.e low coupling, high cohesion, moderate
Group Smells in group complexity and proper encapsulation) using three-level scale
Bloaters Long Method, (high, medium, low).
Large Class, b) Granularity: a flaw that affects a method has a
Primitive Obsession, smaller impact on the overall quality than the flaws that
Long Parameter List, affect the classes
Data Clumps. c) Severity: the first two factors refer to design flaw
Object-Orientation Switch Statement, types, which means that all evaluated smells are considered
Abusers Temporary Field, the same type, however this factor is concerned with
Refused Bequest, evaluating each code smell using severity score ( low 1 to
Alternative Class with Different high 10)
Interface. B’an and Ferenc [15] found out by studying 228 subject
Change Preventers Divergent Change, systems antipatterns and relationship with overall
Shotgun Surgery, maintainability of the system using ColumbusQM model
Parallel Inheritance, that the more antipatterns (code smells) a system contains
Hierarchies. the less maintainable it will be, meaning that it will most
likely cost more time and resources to execute any changes
Dispensables Lazy Class,
Data Class, IV. CODE SMELLS DETECTION
Duplicate Code,
Detecting code smells is a very important and exhausting
Dead Code, task, however Fowler et. al. [4] didn’t provide any
Speculative Generality. mechanism to detect code smells using any metrics other
Couplers Feature Envy, than subjective evaluation of the code and indicators-based
Inappropriate Intimacy, search method, which requires manual review process to find
Message Chains, the described code smells.
Middle Man. Fontana et. al. [6] proposed a metrics-based approach that
uses a set of metrics (CK metric suite) at code level to detect
III. CODE SMELLS EFFECTS using specific thresholds the existence of code smells.
A. Effect of code smells on Software defects: Sharma and Spinellis [7] summarized the approaches in
literature to detect code smells under five categories of
Many researchers studied the relationship between code
smells detection:
smells and design flaws in the software, other researches
focused on empirical investigations of the effect of code a) Metrics-Based smell detection
smells on maintenance effort and future software defects.
b) Rules/Heuristic-based smell detection
Li et al. [12] Investigated the correlation between code
c) History-Based smell detection
smells and number of software defects by observing defects
in industrial-strength systems and concluded that the d) Machine-Learning based smell detection
presence of code smells namely the shotgun surgery code e) Optimization Based smell detection
smell was positively associated with the number of software
defects in the classes
Rasool et.al [16] classified detection mechanisms into
Monden et. al.. [13] performed an analysis of legacy a) Dynamic source analysis: Examines the cause-
systems written in COBOL and concluded that cloned effect relationship of smells during execution
(duplicated) code is more reliable (less prone to errors) but
requires more effort for maintaining than not cloned code. b) Static source analysis: Technique that examines the
properties of smells & their impact without executing the
Rahman et. al. [8] found similarly that cloned code is less system
prone to errors.
And then divided the static source analysis classification
Olbrich et al. [11] reports that smelly structures can into:
contain more than defects than other kinds of code structures. a) Behavioural
B. Effect of Code Smells on Software Maintenance: b) Empirical
Researchers conducted studies to show the empirical c) Methodological
evidence of code smells effect on maintainability of the d) Linguistic
system and empirical analysis of the effectiveness of code
smells refactoring on maintainability the system e) Algorithm-based analysis
All detecting processes in the literature studied uses one of
Marinescu [14] defined three factors when quantifying the following methods:
the effect of code smells (design flaws):
a) Automated Based assessment
a) Influence: How strongly the design flaw affects the b) Semi-Automated Based assessment
good quality according to Coad and Yourdon’s four criteria
c) Manual Subjective asssessment
664
665
optimal combination of metrics to cover all different types [10] D. P. Tegarden, S. D. Sheetz, and D. E. Monarchi, “A software
complexity model of object-oriented systems,” Decision Support
of software is impossible because the detection problem Systems, vol. 13, no. 3–4, pp. 241–262, Mar. 1995.
domain has many variables that cannot be covered by [11] S. M. Olbrich, D. S. Cruzes, and D. I. K. Sjoberg, “Are all code
metrics indicators only. smells harmful? A study of God Classes and Brain Classes in the
Therefore, machine-learning, optimization-based evolution of three open source systems,” (:unav), Sep. 2010.
approaches, and recommendation systems [18], [19], [20] [12] W. Li and R. Shatnawi, “An empirical study of the bad smells and
are proposed to help tackle this difficulty. We surveyed class error probability in the post-release object-oriented system
evolution,” Journal of Systems and Software, vol. 80, no. 7, pp.
three of these algorithms (Table 2), and we found that the 1120–1128, Jul. 2007.
empirical evidence show that such algorithms are [13] A. Monden, D. Nakae, T. Kamiya, S. Sato, and K. Matsumoto,
performing well in detecting smells compared to metrics- “Software quality analysis by code clones in industrial legacy
based solutions such as DÉCOR. software,” in Proceedings Eighth IEEE Symposium on Software
However, machine learning algorithms depends on the Metrics, Ottawa, Ont., Canada, 2002, pp. 87–94.
availability and accuracy of training data and lack of such [14] R. Marinescu, “Measurement and quality in object-oriented design,”
in 21st IEEE International Conference on Software Maintenance
training data can be challenging and results in inefficient (ICSM’05), Budapest, Hungary, 2005, pp. 701–704.
algorithms [19] and it is still unknown in literature if [15] D. Bán and R. Ferenc, “Recognizing Antipatterns and Analyzing
machine learning algorithms can scale to cover all known Their Effects on Software Maintainability,” in Computational Science
code smells [7]. and Its Applications – ICCSA 2014, vol. 8583, B. Murgante, S.
Misra, A. M. A. C. Rocha, C. Torre, J. G. Rocha, M. I. Falcão, D.
Also, optimization algorithms depend on optimizing the Taniar, B. O. Apduhan, and O. Gervasi, Eds. Cham: Springer
metrics combination and their threshold values can limit the International Publishing, 2014, pp. 337–352.
algorithms in the same way as metrics-based algorithms [7]. [16] F. Sabir, F. Palma, G. Rasool, Y.-G. Guéhéneuc, and N. Moha, “A
systematic literature review on the detection of smells and their
evolution in object-oriented and service-oriented systems,” Software:
VI. CONCLUSION: Practice and Experience, vol. 49, no. 1, pp. 3–39, Jan. 2019.
[17] M. Kessentini, H. Sahraoui, M. Boukadoum, and M. Wimmer,
In this paper, we have analyzed the harmfulness of code “Search-Based Design Defects Detection by Example,”
smells as design defects that adversely affect the software in Fundamental Approaches to Software Engineering, vol. 6603, D.
maintenance and quality of software. We surveyed the effect Giannakopoulou and F. Orejas, Eds. Berlin, Heidelberg: Springer
Berlin Heidelberg, 2011, pp. 401–415
of code smells on both software error-proneness and
[18] B. Hawashin, and A. Mansour, “An Efficient Agent-Based System
maintainability. to Extract Interests of User Groups,” Proceedings of the World
We discussed the code smells detection problems and Congress on Engineering and Computer Science ,vol.1 , 2016.
concentrated on the issue of finding the optimal metrics [19] A. M. Mansour, M. A. Obaidat, and B. Hawashin, “ Elderly people
combination for detecting code smells. We surveyed some health monitoring system using fuzzy rule based approach”,
of the researches that have been recently conducted to solve International Journal of Advanced Computer Science and
Applications (IJACSA), 6(12), 2014.
the problem of finding the optimal metrics combination for
[20] B. Hawashin, A. M. Mansour, T. Kanan, and F. Fotouhi, “An efficient
code smell detection among the set of candidate ones. cold start solution based on group interests for recommender
We also discussed three of machine-learning and systems”, Proceedings of the First International Conference on Data
optimization-based approaches to tackle this problem and Science, E-learning and Information Systems, pp. 26, October, 2018.
their overall precision and recall percentages.
REFERENCES
666