Topic: PsychologyBehavior

Last updated: November 7, 2019

Abstract-Refactoring is the key to improve software maintainability, reduce complexity and get clear code with the ability to understand and modify it in efficient way. In this paper we introduce four refactoring techniques which they are: Extract Class, Extract Superclass, Encapsulate Field and Pull up Method to discover their effect on code maintainability depend on several software attributes; Analyzability, Changeability, Stability and Testability. We found that only Pull up Method can increase the maintainability and the other refactoring methods have negative effect on the maintainability which had decreased significantly; note that we calculate maintainability after and before refactoring for comparative operations. INTRODUCTIONWith the huge amount of development, especially in software, The code become more complex, difficult to understand and difficult to maintain. hence. Developers always seek to make a software has a lot of features that allow to use it in away there is understandable and clear, one of the methods that can affect the software is refactoring. Refactoring is considered as a controllable process that can change the software structure without changing its behavior.

The main idea is to reallocate code elements such as classes, methods and others across class hierarchy to facilitate modification and extension (Mens et al.,2004). Software development tends to use refactoring in order to improve software quality, and this consider as improving understandability, maintainability, flexibility and reusability. But otherwise, there are some ricks involved in using refactoring such as it may produce bugs that are difficult to solve or maybe inflexible design will cost too much to modify. But still one of the best techniques to handle many problems facing the programmers. One of the objectives of developers testing code is to growth software quality which depends on testing suites which in turn used to detect software faults.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

The most common approach used is code coverage that enable to test the code quality because it based on describe the statement coverage, branch coverage and path coverage of the software testing suites also there are many studies supported that there is a relationship between code coverage and fault detection (Inozemtseva et al.,2014)Refactoring include many techniques that implement on the code. The refactoring techniques we investigated as follow:Extract class: if the class is very complicated this refactoring technique can help to create new class and transfer some of relevant methods from the old class to the new class. Hence the code of will become more clear and understandable.

Extract Superclass: helps to decrease complexity and code become more flexible to solve problems and future developments by build up a shared superclass and move all similar methods from two classes to it.Pull up method: move the identical methods or variables from the subclass into relevant superclass which disposes of duplicated code.Encapsulated Field: to hiding object data and disallow to other object to access and modify the data of your object without any check or access privilege, this can be done by encapsulated field which helps to convert public data members with getter and setter methods.Change method signature: complete change in method by changing its name, type, add or remove parameter and change the order of parameter, it will automatically change all references to the identical method.In this paper we are going to evaluate the effect of refactoring methods (Extract Class, Extract Superclass, Encapsulate Field and Pullup Method) on software quality attributes by measure quality metrics on six open source java projects before and after refactoring. This paper is organized as follow : the first section for related work, the second for methodology and it divided into several subsections, which they are; introduce the software quality attributes, describe each refactoring method with brief example moreover discover the result for each refactoring method calculated by software metrics the last section for occlusion.Related WorkInozemtseva et al.

,(2014) consider as extend study to evaluate the relationship between test suite size, coverage and detect fault effectiveness applied on five large java project. The main purpose is to discover if test suite coverage provide better fault detection when the test suite size is observed, the result indicated that the high level of coverage do not mean the test suite is more effectiveness. Spinellis et al.(2007) use different open source project such as Appache, MySQL Connector/J and JBoss Hibernate to effect the refactoring quality on software, and the shared result of those project are two suggestions; the first, is not necessary to improve software quality by refactoring and the second, developers have no effective way to use refactoring to get the best quality of software. Simon et al(2001) use different refactoring technique; Move method , Move attribute , Extract class and Inline method also use CASE tool to implement the methods, the result was positive and shows that refactoring can improve and increase software quality. Alshyab et al(2011) Comparison between internal and external quality attributes to make classification for refactoring methods in order to help developers choose suitable refactoring techniques.Wijayanayake et al.(2013) different external measure has been appointed {analyzability, changeability, time behavior and resource utilization } to discover the impact of refactoring techniques on software quality notice that ten methods was used , refactoring techniques produce disaster results on each measure.

Chi et al.(2005) discover the relationship between code coverage and the ability of detect faults which is not steady according to different testing environments such as (functional testing and random testing) use several type of code coverage; block coverage, decision coverage, C-use and P-use, the ability of code coverage in fault detection is higher in functional testing rather than functional testing. Bois et al.(2003) tries to find metrics that help developers to provide best quality of software by using refactoring, but at the beginning, study the impact of refactoring on internal software quality using different refactoring techniques which they are: Extract Method, Encapsulated field and Pull up method implemented on “Inellij IDEA” and “Eclipse”. These methods was characterized on AST representation and use the result to analyze the impact of refactoring by object oriented program quality metrics, the result was positive and shows feasibility of implement these techniques. Chaparro et al.

(2014) use RIPE (Refactoring Impact PreEdicate) method to analyze the impact of refactoring on software and using different metrics to support the operation such as (Coupling Between Object) and others. This study based on 12 refactoring methods and 11 metrics, the result was in the positive side, RIPE predict 38% of 8,103 metrics values. This method is recommended and can help developers when refactoring cause radical change in the code.

Kataoka et al.(2002) applied quantitative technique to evaluate the maintainability on software after implement refactoring and describe the impact of refactoring using coupling metrics and after the experiment has been shown it is useful method. Bashir et al.

(2017) the purpose here is to choose refactoring methods that give the best result and improve software quality, this study based on Fine-granular methodology, which divided the experiment into several phases, note that the whole experiment is done with nine case studies. The result shows improving of quality metrics using refactoring methods (Extract method, Extract class and Move method) which in turn led to higher match between nine cases.Fontana et al(2011) the process start by identify the metrics that used to evaluate the system which they are coupling, cohesion, number of methods, response for a class, tight class cohesion and weighted method per class, this will led to detect the code smell.

Then applying refactoring on the code, after refactoring they recomputed the metrics on software then analyze the result to introduce the best of refactoring techniques that affect the quality of analyzed system. The result shows that it is difficult to decide if refactoring remove code smells or it produce other unknown smells. Kumari1 et al(2014)The researches discover the effect of using refactoring methods on specific software quality attribute, in this studied was used 14 refactoring techniques, Intellij Idea: IDE tool to determine the effect of refactoring, and nine software attributes which was computed after and before refactoring.As a conclusion, refactoring could be a positive choice and sometime negative one, because the result shows that refactoring not definite to be a way to improve software quality and it depends on what the developer choose of refactoring method.

Khrishe et al(2016) The experiment start with using three refactoring methods, {extract class, extract method and replace temp with query}, the main idea here is to apply these refactoring techniques on six experiments with different order and compute the code before and after refactoring using several metrics, the metrics tool was called {Source Monitor}, The result showed that applying refactoring methods in different order provide different effects on code. Kannangara at al(2015) The main goal of the study is to assure or not assure if refactoring develop software quality and it was applied on the internal and external measures, the experiment applied on c# open source project and visual studio is the selected tool. According to the conclusion, the result of external measures did not improve the quality of the code after refactoring, in the internal measure; none of them make any improvement except maintainability has positive effect in code quality, note that this positive effect was on project on which refactoring was applied higher than non-refactoring project.

Ch´avez et al(2017)This study use 23 open source projects to determine the effect of refactoring on internal software quality using 11 refactoring methods, the study is divided into two part, the first one is to determine whether refactoring techniques can be applied on code with critical internal quality attributes and the second to figure the effect of refactoring on internal quality attributes the result showed 65% of internal quality attribute was positive impact and the rest 35% was unaffected. Malhotra et al(2016) The study depends on discover the impact of refactoring on maintainability applied on five open source software, the result was compared between the code after and before refactoring. Notice that five refactoring methods were used, and the result was positive and shows that some refactoring method can amelioration the software quality such as consolidate conditional Expression and Extract Method. Also could be dangerous tool that may destroy the code and decrease maintainability such as Extract class and Encapsulate field. Cinn´eide et al(2011)The study involve in enhanced testability through get better result in cohesion measure using automated refactoring. The experiment on java software, and applied test cases to show the extent of complexity in typing it after and before refactoring. The result was probable that refactoring can be away to improve testability, but it need more of work and testing.

Chug et al(2017) This experiment is based on reduce faults and reach high level of software quality through applying refactoring methods on several open source software, The conclusion was in the positive side and apper that refactoring can decrease the number of faults in software system, and the percentage of errors that have been reduced as follow: 20%, 16%, 4%, 14% and 5%, it’s a probability ratio that cannot be underestimated. Sz?oke et al(2016) Can refactoring improve maintainability? This is the main question in this study which focus on applying refactoring methods on six large project software, The result introduce as follow: the output of single refactoring on the comprehensive maintainability cannot be ascertained, because refactoring may have negative effect on maintainability but in this experiment refactoring effect was useful on software maintainability because was done by a whole period. Jonsson(2017) The study based on discover the effect of refactoring on code quality but on legacy system. The result shows developed in software maintainability in which refactoring improve it in several quality metrics such as, cyclomatic complexity, line of code and class coupling. And that point to the simplicity to affect the code and develop it after refactoring.Research MethodologyThe importance of refactoring be in reducing complexity and increasing other quality metrics of software. Hence this study we will apply test coverage in open source java project modified with several refactoring methods using “Eclipse” tool then compute the complexity using predefined tool, this will also apply on code before refactoring. The result before and after refactoring will be compared moreover impact analysis will be performed for detecting refactoring faults to discover if refactoring have positively affect on the code or vise versa.

In our experiment we applied four refactoring techniques java project open source using eclipse platform, we have made four copies of the same project in order to applied each refactoring method individually on the whole project to verity the validity of the result on discovery the effect of refactoring on program quality. We use four software quality attribute which they are: Analyzability, changeability, stability and Testability. Analyzability: Is the strength of the software product to be testable if there are any defects or to discover the causative of these defects.Changeability: The degree of complexity of amendment software, such as fix bugs, add new characteristics or make change for the environment of the software.Stability: Is the ability of reducing the unpredicted defects from changeability.Testability : Is the process of make sure that program has no errors and was built as required.

Note that each of these attribute contain several metrics as show below in table 1 Chawla(2015). Moreover we use 1.3.8 tool to compute these metrics.Quality Attribute Design Metric Source (Tool) Metric NameAnalyz-Ability Cyclomatic number(CComplexity) Metrics 1.3.8VGNumber of statements (Size)Metrics 1.

3.8TLOCComments frequency(Comments) – Comments(in %)Weighted methods per class (Complexity)Metrics 1.3.8WMCMethod inheritance factor (MethodInheri)UnderstandMFAChange-ability Average size of statements (avgSize)Metrics 1.3.8TLOCNumber of nested levels (Nesting)Metrics 1.3.8NBDCoupling between objects (Coupling)UnderstandCBOLack of cohesion(LCohesion) Metrics 1.

3.8LCOMDepth of inheritance tree (Hierarchies)UnderstandDITPolymorphism Factor(Polymorph) Metrics 1.3.8NORM/NOMMethod inheritance factor (MethodInheri)UnderstandMFAStabilityNumber of children(Subclasses) Metrics 1.3.8NSCCoupling between objects (Coupling)UnderstandCBODepth of inheritance tree (Hierarchies)UnderstandDITNumber of entry/exit points (EntExt)- 1Directly called components(Communication) UnderstandRFCTest-ability Cyclomatic number(CComplexity) Metrics 1.

3.8VGNumber of nested levels (Nesting)Metrics 1.3.8NBDResponse for a class(Communication) UnderstandRFCNumber of children(Subclasses) Metrics 1.

3.8NSCOutward coupling(EffCoupling) Metrics1.3.8CETable1:Metrics and tool supportAnd the result of each software attribute for java project before refactoring in the table below :Quality Attribute Design Metric ResultAnalyzability VG 4.195?TLOC 8563Comments 1WMC 28.744MFA 0.

2542Changeability TLOC 4281.5NBD 1.282CBO 3.4545LCOM 0.

154DIT 1.3295NORM/NOM 0.05668MFA 0.2542Stability NSC 0.314CBO 3.4545DIT 1.3295EntExt1RFC 6.

4318Testability VG 4.915NBD 1.282RFC 6.4318NSC 0.314CE 8.875Table2: Result of software quality metrics for java project before refactoringExtract ClassWe start with extract class. Class by their nature small and can perform small or huge tasks according to its implementation.

It can contain many methods related or unrelated to each other, this leads to difficult to read modify, understand and maintain. In this case we can extract some of relevant methods to a new class and this done by creating new class and transfer the relevant methods from the existing class. As the following example in figure 1Firure1: Brief example on extract classWe applied Extract class on 14 different classes from three different packages. Extract class start by choose the appropriate class that contain several methods, after that we can choose which method will move to the new class. The result of each software quality attributed for the Extract class is appearing in the following table.Quality Attribute Design Metric ResultAnalyzability VG 4.034?TLOC 9078Comments 1WMC 25.173MFA 0.

190Changeability TLOC 4539NBD 1.219CBO 3.09433LCOM 0.215DIT 1.2735NORM/NOM 0.

04258MFA 0.190Stability NSC 0.26CBO 3.09433DIT 1.2735EntExt1RFC 6.71698Testability VG 4.034NBD 1.219RFC 6.

71698NSC 0.26CE 9.75Table3: Result of software quality metrics for java project applied by Extract classExtract SuperclassAnother way to reduce complexity here, we have two classes that contain similar fields and methods, This technique involves about creating shared superclass and transfer all similar methods and fields to the shared class, the original class will be inherited from the superclass as the following example:BeforePublic class school{ Public int stuNumber;private double stuAVG; Public static final int constant=0; Public void public method(){ ……. } Public void hidden method(){ ……} Public void set var Double (double var){ This.

Var Double =var;} Public double get var Double (){ Return var Double; } }After(File school.java) Public class school extends University{ Public int stuNumber; Public void publicMethod(){ ……} Public void hiddenMethod (){ …….} } (New file University.

Java) Public abstract class University{ Private double stuAVG; Public static final int constant=0; Public abstract void public method(); Public void set var Double (double var){ This. Var Double=var;} Public double get var Double(){ Return var Double } }Firure2: Brief example on extract SuperclassAfter applying extract superclass we get the following result:Quality Attribute Design Metric ResultAnalyzability VG 4.722?TLOC 8724Comments 1WMC 24.252MFA 0.5627Changeability TLOC 4362NBD 1.268CBO 3.3714LCOM 0.

133DIT 1.5809NORM/NOM 0.05353MFA 0.5627Stability NSC 0.427CBO 3.

3714DIT 1.5809EntExt1RFC 7.0857Testability VG 4.722NBD 1.

268RFC 7.0857NSC 0.427CE 10.25Table3: Result of software quality metrics for java project applied by Extract Superclass Encapsulate FieldAllow the user to protect the usable fields by make them private and create access methods (set and get).Described in the example below: Firure1: Brief example on Encapsulate FieldAfter applying Encapsulate Field we get the following result:Quality Attribute Design Metric ResultAnalyzability VG 4.442?TLOC 8770Comments 1WMC 29.

547MFA 0.2692Changeability TLOC 4385NBD 1.248CBO 3.4545LCOM 0.

181DIT 1.3295NORM/NOM 0.050813MFA 0.2692Stability NSC 0.314CBO 3.4545DIT 1.

3295EntExt1RFC 7.2613Testability VG 4.442NBD 1.248RFC 7.2613NSC 0.314CE 8.

875Table4: Result of software quality metrics for java project applied by Encapsulate FieldPull Up MethodSeveral subclasses contain common methods with identical behavior we can move these methods into single methods in superclass. After applying change method signature technique we get the following result:Table4: Result of software quality metrics for java project applied by Pull up methodQuality Attribute Design Metric ResultAnalyzability VG 4.374?TLOC 8127Comments 1WMC 26.14MFA 0.30744Changeability TLOC 4063.

5NBD 1.257CBO 3.5681LCOM 0.148DIT 1.3295NORM/NOM 0.0552MFA 0.30744Stability NSC 0.

314CBO 3.5681DIT 1.3295EntExt1RFC 6.8863Testability VG 4.374NBD 1.257RFC 6.8863NSC 0.

314CE 9Implementing Quality MetricsIn this section we will introduce the result of each refactoring techniques calculated by software quality metrics which were mentioned previously, before and after refactoring Quality attribute Before Refactoring Extract Class Extract Superclass Pull up Method Encapsulate FieldAnalyzability -2408.5306 -2551.839 -2452.192 -2285.419 -2466.56Changeability -565.208 -591.011 -568.

142 -529.33 -571.069Stability -2.5816 -2.5442 -2.7733 -2.

7009 -2.7558Testability -4.5163 -4.5299 -4.

9026 -4.9324 -4.5586Table5: Result of software quality attribute for java project after and before refactoringAnd the results for maintainability after discover the outcome of each quality attribute in the table below:Project ResultBefore Refactoring -759.

6091Extract Class -803.1987Extract Superclass -772.1114Pull up Method -719.

6969Encapsulate Field -780.0481Table5: Result of software maintainability for java project after and before refactoringConclusionIn this experiment we have introduce different refactoring methods (Extract class, Extract Superclass, Pull up method and Encapsulate Field) in order to determine their impact on software maintainability, note that we realize on knowing the effect of maintainability on several software attribute; Analyzability, Changeability, Stability and Testability. The result shows that only Pull up method can improve the maintainability of the software and the other refactoring methods reduce it, moreover beside the test coverage also Pull up method get high rate in test coverage reach to 8.8% while the code before refactoring was 8.5%, the other refactoring techniques; Extract Class, Extract Superclass and Encapsulate Field were 9.

5%, 8.6% and 8.5% respectively. References1 Mens.T and Tourwe.T(2004)” A Survey of Software Refactoring”,IEEE TRANSACTIONS ON SOFTWARE ENGINEERING,Vol.30 ,NO.

2 ,PP.126-139.2 Inozemtseva.L and Homles.R(2014)” Coverage Is Not Strongly Correlatedwith Test Suite Effectiveness”,PP.

435-445.3 Gopinath.R, Jensen.C and Groce.

A(2014)” Code Coverage for Suite Evaluation by Developers”,Procedding of the 36th International Conference on software Enginering,PP.72-82.4 Namin.A.S and Andrews.

J.H(2009)” The Influence of Size and Coverage on Test Suite Effectiveness”,pp.57-67.5 Chong.y, Wang.M and Xiong.Y(2016)” Empirical Evaluation of Test Coverage forFunctional Programs”,IEEE Press.

6 Spinellis.D and Stroggylos.K(2007)” Refactoring – Does it improve software quality?”, Fifth International Workshop on Software Quality (WoSQ’07).7 Simon.

F , Steinbuekner.F and Lewerentz.C(2001)”Metrics Based Refactoring”,IEEE Press,PP.30-38.8 Alshyab.M and Elish.

K.O(2011)” A Classification of Refactoring Methods Based on Software Quality Attributes” Arab J Sci Eng ,VOL.36, NO7,PP.1253-1267. 9 Wijayanayake.

W.M.J.

I and Kannangara.S.H(2013)” Impact of Refactoring on External Code Quality Improvement: An Empirical Evaluation”2013 International Conference on Advances in ICT for Emerging Regions (ICTer),PP.60-67.10 Bashir.

S,Lee.S.P and Yung.C.C(2017)” A methodology for impact evaluation of refactoring on external quality attributes of a software design”,International Conference on Frontiers of Information Technology,PP.183-188.11 Bois.B.D and Mens.T(2003)” Describing the Impact of Refactoring on InternalProgram Quality”,ResearchGate,PP.1-13.12 Chaparro.O, Bavota.G, Marcus.A and Penta,M,D(2014)” On the Impact of Refactoring Operations on Code Quality Metrics”,IEEE Press,PP.456-460. 13 Chi.X and Lyu.M.R(2005)” The Effect of Code Coverage on Fault Detection under Different Testing Profiles”,International Workshop on advances in mode-based testing.14 Kataoka.Y, Imai.T and Andou.H(2002)” A Quantitative Evaluation of Maintainability Enhancement by Refactoring”,IEEE Press .15 Shahjahan.A, Butt.W.H, Ahmad.A.Z(2015)” Impact of Refactoring on Code Quality by using Graph Theory: An Empirical Evaluation”,SAI Intelligent Systems Conference,PP.595-600.16 Fontana.F.A and Spinelli.S(2011)” Impact of Refactoring on Quality Code Evaluation “pp.37-4017 Kumari1.N and Saha2,A(2014)” EFFECT OF REFACTORING ON OFTWARE QUALITY ” pp.37.4618 Khrishe.Y and Alshayeb.M(2016)” An Empirical Study on the Effect ofthe Order of Applying Software Refactoring”, 7th International Conference on Computer Science and Information Technology (CSIT)19 Kannangara.S.H and Wijayanak.W.M.J.I(2015)” AN EMPIRICAL EVALUATION OF IMPACT OF REFACTORING ON INTERNAL AND EXTERNAL MEASURES OF CODE QUALITY”, International Journal of Software Engineering & Applications (IJSEA), Vol.6, No.1,PP.51-6720 Ch´avez.A, Ferreira,.I , Fernandes,.E, Cedrim,.D, Garcia.A(2017)” How does refactoring a€ect internal quality a.ributes? “pp.74-8321 Malhotra.R and Chug.A(2016)” An Empirical Study to Assess the Effects ofRefactoring on Software Maintainability “, Conference on Advances in Computing, Communications and Informatics (ICACCI),pp.110-11722 Cinn´eide.M, Boyle.D , Moghadam.I.H(2011)” Automated Refactoring for Testability “, Fourth International Conference on Software Testing,PP.437-44323 Chug.A , Gupta.M(2017)” A Quality Enhancement through Defect Reduction using Refactoring Operation”24 Sz ?oke,.G, Antal,.G, Nagy,.C, Ferenc.R, Gyimóthy.T(2016)” Empirical study on refactoring large-scale industrial systems and its effects on maintainability “25 Jonsson.A(2017)” The Impact of Refactoring Legacy Systems on Code Quality Metrics “26 Chawla.M.K and Chhabra.I(2015)”SQMMA: Software Quality Model for Maintainability Analysis “

x

Hi!
I'm Piter!

Would you like to get a custom essay? How about receiving a customized one?

Check it out