DocumentCode :
1334363
Title :
Evaluation of the ´replace constructors with creation methods´ refactoring in Java systems
Author :
Counsell, Steve ; Loizou, G. ; Najjar, R.
Author_Institution :
Sch. of Inf. Syst., Comput. & Math., Brunel Univ., Uxbridge, UK
Volume :
4
Issue :
5
fYear :
2010
fDate :
10/1/2010 12:00:00 AM
Firstpage :
318
Lastpage :
333
Abstract :
Class constructors play an indispensable role in the Java language as a mechanism for object creation. However, little empirical evidence exists on constructors, trends in their composition and how a class with too many constructors might influence its understandability by developers. Herein, the authors investigate the applicability of the `replace constructors with creation methods` (RCwCM) refactoring of Kerievsky in five Java systems. The RCwCM was manually applied to a set of classes from each of the five systems in classes containing three or more constructors. The benefits of this refactoring include improved code readability and encapsulation, program understanding and to a lesser extent possible elimination of code duplication. Within each of the five systems, evidence of scope for applying the RCwCM refactoring based on the number of classes with multiple constructors was found. However, problems were encountered that limited its application. These are the nature of inheritance and the different styles of accessing class constructors. In the former, account has to be taken of multiple dependencies if the class is not a leaf class; in the latter, the `super` construct requires careful handling. When considered against the benefits that the RCwCM provides, care needs to be exercised. As with any refactoring effort, the short and long-term benefits need to be compared with the expense outlay (developer time and effort) as well as the opportunity cost.
Keywords :
Java; object-oriented programming; Java language; RCwCM method; RCwCM refactoring; class constructors; code duplication; code encapsulation; code readability; object creation mechanism; replace constructors with creation methods;
fLanguage :
English
Journal_Title :
Software, IET
Publisher :
iet
ISSN :
1751-8806
Type :
jour
DOI :
10.1049/iet-sen.2009.0010
Filename :
5585607
Link To Document :
بازگشت