The role of constructors in the context of refactoring object-oriented systems

R. Najjar, S. Counsell, G. Loizou, K. Mannock
{"title":"The role of constructors in the context of refactoring object-oriented systems","authors":"R. Najjar, S. Counsell, G. Loizou, K. Mannock","doi":"10.1109/CSMR.2003.1192418","DOIUrl":null,"url":null,"abstract":"Constructors play an essential role in object-oriented (OO) languages as a means of object creation. Yet, very little empirical evidence exists on constructors, trends in their composition and how they impact comprehension and encapsulation of OO classes. In this paper, we empirically investigate the opportunities, benefits and problems of refactoring class constructors across a sample of classes from five Java systems. The refactoring used, namely, replacing multiple constructors with creation methods, was applied to each of a set of classes containing three or more constructors. Empirical results showed benefits in terms of removed (duplicated) lines of code across the majority of systems. They also showed the potential for improved class comprehension by the creation of non-constructor methods (as a replacement for constructors) and improved encapsulation of class elements through use of a private catch-all constructor. We also provide evidence from five C++ systems which suggests similar trends in constructors to those found for Java. In terms of problems encountered, frequent and inconsistent use of the super construct made refactoring prohibitively difficult in some cases; the existence of Java interfaces also means a lack of scope for constructor refactoring. The results indicate clear and tangible benefits to be gained from investigation and implementation of refactoring techniques in Java, but with caution being exercised in certain cases; refactoring in practice is not as straightforward as the theory suggests.","PeriodicalId":236632,"journal":{"name":"Seventh European Conference onSoftware Maintenance and Reengineering, 2003. Proceedings.","volume":"1 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2003-03-26","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"32","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Seventh European Conference onSoftware Maintenance and Reengineering, 2003. Proceedings.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/CSMR.2003.1192418","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 32

Abstract

Constructors play an essential role in object-oriented (OO) languages as a means of object creation. Yet, very little empirical evidence exists on constructors, trends in their composition and how they impact comprehension and encapsulation of OO classes. In this paper, we empirically investigate the opportunities, benefits and problems of refactoring class constructors across a sample of classes from five Java systems. The refactoring used, namely, replacing multiple constructors with creation methods, was applied to each of a set of classes containing three or more constructors. Empirical results showed benefits in terms of removed (duplicated) lines of code across the majority of systems. They also showed the potential for improved class comprehension by the creation of non-constructor methods (as a replacement for constructors) and improved encapsulation of class elements through use of a private catch-all constructor. We also provide evidence from five C++ systems which suggests similar trends in constructors to those found for Java. In terms of problems encountered, frequent and inconsistent use of the super construct made refactoring prohibitively difficult in some cases; the existence of Java interfaces also means a lack of scope for constructor refactoring. The results indicate clear and tangible benefits to be gained from investigation and implementation of refactoring techniques in Java, but with caution being exercised in certain cases; refactoring in practice is not as straightforward as the theory suggests.
构造函数在重构面向对象系统中的作用
构造函数作为对象创建的一种手段,在面向对象(OO)语言中扮演着重要的角色。然而,关于构造函数、它们的组成趋势以及它们如何影响OO类的理解和封装的经验证据很少。在本文中,我们以五个Java系统中的类为例,对重构类构造函数的机会、好处和问题进行了实证研究。所使用的重构,即用创建方法替换多个构造函数,应用于包含三个或更多构造函数的一组类中的每个类。经验结果显示了在大多数系统中删除(重复)代码行的好处。它们还展示了通过创建非构造函数方法(作为构造函数的替代品)来改进类理解的潜力,以及通过使用私有的全捕获构造函数来改进类元素的封装。我们还提供了来自五个c++系统的证据,这些证据表明构造函数的趋势与Java的相似。就遇到的问题而言,超级构造的频繁和不一致的使用在某些情况下使重构变得异常困难;Java接口的存在也意味着缺乏构造函数重构的作用域。结果表明,在Java中研究和实现重构技术可以获得明确而切实的好处,但在某些情况下要谨慎行事;实践中的重构并不像理论所建议的那样简单。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信