0% found this document useful (0 votes)
14 views4 pages

Lafi2019 Code Smells

Software evolution is an inevitable need in most of the modern businesses, software that doesn’t accommodate changes is hard to survive the market needs. Also, software changes can affect the overall design of the software and sometimes in a corrupting way, affecting the maintainability and evolvability of the software, which introduces technical debt that needs to be solved by continuous refactoring and restructuring of software. Code smells are useful indicators to identify the parts

Uploaded by

Mohammed Lafi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Lafi2019 Code Smells

Software evolution is an inevitable need in most of the modern businesses, software that doesn’t accommodate changes is hard to survive the market needs. Also, software changes can affect the overall design of the software and sometimes in a corrupting way, affecting the maintainability and evolvability of the software, which introduces technical debt that needs to be solved by continuous refactoring and restructuring of software. Code smells are useful indicators to identify the parts

Uploaded by

Mohammed Lafi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

                    

2019 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT)

Code Smells Analysis Mechanisms, Detection


Issues, and Effect on Software Maintainability
Mohammed Lafi Joseph Wassily Botros Hamzah Kafaween
Department of Software Engineering Department of Software Engineering Department of Software Engineering
AL- Zaytoonah University of Jordan Alzaytoonah University of Jordan Alzaytoonah University of Jordan
Amman, Jordan Amman, Jordan Amman, Jordan
[email protected] [email protected] [email protected]

Ahmad Bassam Al-Dasoqi


Abdelfatah Al-Tamimi
Department of Software Engineering
Department of Software Engineering
Alzaytoonah University of Jordan
Al-Zaytoonah University of Jordan
Amman, Jordan
Amman, Jordan
[email protected]
[email protected]

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

978-1-5386-7942-5/19/$31.00 ©2019 IEEE 663


                    

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
                    

Sahin et.al. [18] proposed tackling the problem as a Bi-


But still “There are many smells that cannot be detected Level optimization problem (BLOP) (Fig. 2) and proposed a
by the currently available metrics alone. For example, we two-level method for solving BLOP, evaluation for the
cannot detect rebellious hierarchy, missing abstraction, method was conducted on seven code smells detection on
cyclic hierarchy and empty catch block smells using nine open source projects with the result of 88% precision
commonly used metrics.” [7] and more than 90% of recall (Table 2).
Mansour et. al. [9] proposed a multi-objective search-
Even with the literature and market advancement in based approach for the generation of code-smells detection
providing solutions that employ an automated based rules from code-smells and well-designed examples, aiming
approach that reduce the amount of time /expertise needed at finding the combination of metrics that:
to conduct a thorough evaluation of software code base, still a) Maximize the coverage of a set of code-smells
there are limitations regarding the evaluation of the result of examples collected from different systems.
such tools and taking the right refactoring decisions.
b) Minimize the detection of examples of good design
Mansoour et. al. [9] found some issues in code smells
practices (false positives)
detection using metrics which can be summarized as the
following: The approach was evaluated by using it on seven open
source projects to detect three different code smells (Blob,
a) Threshold problem: An appropriate threshold value
Spaghetti code, Functional decomposition) and successfully
is not trivial to be defined.
detected most of the expected code smells with an average
b) Metrics combination: Manual selection of the best of 86% of precision and 91% of recall (Table 2).
combination of metrics that formalize some symptoms of
code-smells is challenging.
c) Definitions translation: Translation of code-smell
definitions into metrics is not straightforward.
d) Imprecise Metrics: Same metrics can identify
different code smells which undermines precision.
e) False positives: detection of well-designed parts of
the code as smelly structures.
Fontana et.al. [10] also found that the interpretation of
threshold values and measures is challenging across
different tools. the research also observed the results from
using different tools with different detection mechanism will
always differ, potentially because of the discrepancy of
threshold and metrics definitions.
Kessintini et. al. [17] proposed a search-based defects
detection by example, which is an approach that uses Fig. 2. Bi-Level Optimization approach [18]
knowledge from previously manually inspected projects in
order to detect design defects by generating new detection
rules based on the combination of software quality metrics TABLE II. COMPARISON OF CODE SMELLS DETECTION APPROACHES
(Fig.1). Detection Algorithm / Avg. Avg.
The rules generation is a combinatorial optimization Research Mechanism Method Precision Recall
problem. And since the number of possible combinations Kessintini Optimization- Examples
quickly becomes huge with the increase of quality metrics et. al [17] Based Search-Based 94% 97%
using deterministic search is not practical, hence the use of Sahin et.al. Optimization- BILevel
heuristic search. [18] Based Optimization 88% 90%
The Searching Algorithms that were used by Kessintini: Machine- Multi-
a) Harmony Search (HS) Mansour Learning Objective
et. al. [9] Based Search-Based 86% 91%
b) Particle Swarm Optimization (PSO)
c) Simulated Annealing (SA)
The Kessintini search-based method was simulated on 2 V. DISCUSSION & ANALYSIS:
open source projects to detect 3 code smells Blob, Spaghetti Many researchers proposed algorithms to tackle the
code, Functional decomposition. difficulties of code smells detection. Code smells can be
detected in software code through many techniques such as
manual review, machine-learning, and optimization-based
approached. Manual review of the code is the most basic
and efficient but this approach is not productive and cannot
be scaled.
Fig. 1. Search-based by example approach [17] To automate code smells detection process, the
researchers depend on specific algorithms to detect code
smells using combination of metrics. But, finding the

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

[1] E. W. Dijkstra, “Letters to the editor: go to statement considered


harmful,” Communications of the ACM, vol. 11, no. 3, pp. 147–148,
Mar. 1968.
[2] A. J. Riel, Object-oriented design heuristics. Reading, Mass:
Addison-Wesley Pub. Co, 1996.
[3] W. J. Brown, Ed., AntiPatterns: refactoring software, architectures,
and projects in crisis. New York: Wiley, 1998.
[4] M. Fowler and K. Beck, Refactoring: improving the design of
existing code. Reading, MA: Addison-Wesley, 1999.
[5] M. V. Mäntylä and C. Lassenius, “Subjective evaluation of software
evolvability using code smells: An empirical study,” Empirical
Software Engineering, vol. 11, no. 3, pp. 395–431, Jul. 2007.
[6] F. Arcelli Fontana, P. Braione, and M. Zanoni, “Automatic detection
of bad smells in code: An experimental assessment.,” The Journal of
Object Technology, vol. 11, no. 2, p. 5:1, 2012.
[7] T. Sharma and D. Spinellis, “A survey on software smells,” Journal of
Systems and Software, vol. 138, pp. 158–173, Apr. 2018.
[8] F. Rahman, C. Bird, and P. Devanbu, “Clones: What is that
smell?,” (:unav), May 2010.
[9] U. Mansoor, M. Kessentini, B. R. Maxim, and K. Deb, “Multi-
objective code-smells detection using good and bad design
examples,” Software Quality Journal, vol. 25, no. 2, pp. 529–552,
Jun. 2017.

666

You might also like