Evaluating The Impact of Refactoring Techniques Order On Code Maintainability: A Case Study
Evaluating The Impact of Refactoring Techniques Order On Code Maintainability: A Case Study
On Code Maintainability
: A Case Study
Muhammad Imran L165059
Abstract: - Software code refactoring is used to remove their study. Some of them acknowledged that
bad smells and improve code quality. Bad smells are changing the order of refactoring techniques
alarming for long term execution of the code. There is a lot
of research on refactoring techniques. Many studies have
how they are applied will affect the quality of
been conducted on evaluation of impact of refactoring the code in positive sense. While others have
techniques have proved that refactoring enhances the code proved that reordering doesn’t improve the code
quality in many aspects. But no remarkable work is found design quality. So we established a hypothesis
on impact of refactoring techniques sequence that change that order of refactoring techniques will improve
the code quality when same refactoring techniques are
applied in different order. A few researchers conducted the code quality.
their study on impact of sequence of refactoring techniques To prove the established, we conducted a case
but that does not provide some tangible solution or study. We selected a project (HKBApp) to
guideline. In this study, a few experiments are conducted evaluate the impact of refactoring techniques
on a real life java project. Selected project is identified with
some code smells. As a remedy, two refactoring techniques
orders. HKBApp is software written in java to
are organized in different sequences. In each experiment, extract specific data from Oracle for SAP
one sequence is applied and changes in software metrics upload. The software is composed of several
are noted. Similarly refactoring techniques are applied on classes.
project in all sequences. Finally, results are compared as Section II discusses the related work done before
per changes and some suggestion is provided for
implementation of refactoring techniques in certain order on the impact of order of refactoring techniques.
Some of the studies are discussed. What is
I. INTRODUCTION proved in it and criticism on it. Section III is
problem statement. In this section we will
Code refactoring is the process of discussed the purpose of this study in depth.
restructuring existing software code. Changing Section IV is about the Research methodology
the code in a way that it doesn’t affect the discussed in details. Section V discusses the
behavior of the program. There are number of Experiment Setup in details. The experiment
principles or rules to apply refactoring model and project being used etc. Section VI
techniques in order to remove code smells from discusses the results of the study and suggestion
the code. According to Martin Fowler, "a code about usage of refactoring techniques in certain
smell is a surface indication that usually order. Section VII discusses what we concluded
corresponds to a deeper problem in the system. from study and finally, Future work is stated in
A Bad smell is a certain structure in the code section VIII. References are given in Section 9.
that does not fulfill design principles [1]. A
software bug usually causes failure during the II. RELATED WORK
execution of a program. Bad smells are working
code that cause no bugs and yield their expected Even though very few are there who consider
output. However, they indicate a potential the order of refactoring techniques while
problem in the code that could cause bugs; they applying on code to remove bad smells. But still
also make the code less maintainable. Martin there is a plenty of work available to review and
Fowler has identified 22 code smells [2]. When study the work done. In our case, a very
many bad smells occur in the software, many renowned study conducted by Yahya Khrishe
refactoring techniques can be applied to address and Mohammad Alshayeb addressed the topic in
these smells. a very concise way [3]. Worthy researchers have
Researchers have addressed the impact of put the idea for evaluation of order of
ordering of refactoring techniques on code in
refactoring techniques by conducting some quality smells are certain structures in the code
experiment on sample code. that indicate violation of fundamental design
The most renowned work for this study is the principles and negatively impact design quality.
study by Liu et al. [4, 5]. They observe the Code smells are not but rather they are not
relationship between bad smells and the effect of technically incorrect and do not currently
possible sequences of refactoring. However, the prevent the program from functioning. Instead,
objective of this paper is to empirically evaluate they indicate weaknesses in design that may be
whether the order of applying refactoring slowing down development or increasing the
sequence affects the quality of the generated risk of bugs or failures in the future. Bad code
code using different software metrics for smells can be an indicator of factors that
evaluation. contribute to technical debt.
Meananeatra [6] proposed an approach to Code refactoring is the process of restructuring
identifying optimal refactoring sequence that existing source code without changing its
meets four criteria: 1) the number of removed behavior [7]. Refactoring improves
bad smells, 2) maintainability, 3) the size of nonfunctional attributes of the software.
refactoring sequence and 4) the number of Advantages include improved code readability
modified program elements. The main purpose and reduced complexity; it can improve source-
of their work was to help developers to identify code maintainability and create a more
the appropriate refactoring techniques and to expressive internal architecture or object model
select an optimal refactoring sequence based on to improve extensibility. Refactoring applies a
the developer objective. A prototype was series of standardized techniques, each of which
developed which accepts the objective and the is a tiny change in code that either preserves the
code as an input, the input undergoes a specific behavior of the program; Code refactoring may
process that will result in a several refactoring also resolve hidden, dormant, or undiscovered
sequences, a metric value is calculated for each computer bugs or vulnerabilities in the system
sequence, a graph that represents all possible by simplifying the underlying logic and
sequences is constructed and the sequence with eliminating unnecessary levels of complexity
the best value is chosen. [8]. If done poorly it may fail the requirement
Refactoring and evaluation of certain results are that external functionality not be changed,
addressed in concise way for the code quality. introduce new bugs.
So we established a hypothesis about the impact In our study, the addressable thing is evaluation
of reordering the refactoring techniques. of impact of refactoring if order or sequence of
H0 (Null Hypothesis) says that changing the refactoring techniques is changed while applying
sequence of techniques while applying on the it to the code.
code doesn’t yield different results. I.e. there is
no change in source code of software when same IV. RESEARCH METHODOLOGY
refactoring techniques are applied in different
orders. We selected a real life project obtained from a
HA (Alternate Hypothesis) states that changing retail business.
the sequence of same refactoring techniques HKBApp is software developed in Java to
changes the code structure and it impact the extract specific data in specific format from
software design and quality. Oracle DBMS for SAP upload. SAP upload is
configured to accept the extracted data from
Oracle through this application.
III. PROBLEM STATEMENT Project is composed of several classes
responsible for the functionality it is written for.
Code smell, also known as bad smell, in We performed our experiments on the classes
computer programming code, refers to any that contains bad smells in it.
symptom in the source code of a program that This experiment is consisted of few many things
possibly indicates a deeper problem. The way to including HKBApp Source code for experiment,
look at smells is with respect to principles and Eclipse IDE, Jdeodorant plugin for code smell
identification, JHAWK (to measure the software
metrics) and software metrics. We applied
refactoring techniques in several orders on our
code and evaluated the result by JHawk software
metrics tool.
VI. RESULTS
During the practice, we noted the results for
software metrics measured by JHawk. Results
for each experiment are given in the Table II.
Software
Metric
HKBApp Original Sequence 1 Sequence2
HKBSales.java ABSales.java HKBSales.java ABSales.java HKBSales.java ABSales.java
Avg 7.55 7.60 5.53 5.08 5.47 5.08
Cyclomatic
Complexity
Lines of Code 1436 1305 1372 1222 1369 1221
Maintainability 116.72 113.09 50.11 45.38 50.56 45.38
index