Unifying clones with a generative programming technique: a case study

Software clones—similar program structures repeated in variant forms—increase the risk of update anomalies, blow up the program size and complexity, possibly contributing to high maintenance costs. Yet, programs are often polluted by clones. In this paper, we present a case study of cloning in the Java Buffer library, JDK 1.5. We found that at least 68% of the code in the Buffer library was contained in cloned classes or class methods. Close analysis of program situations that led to cloning revealed difficulties in eliminating clones with conventional program design techniques. As a possible solution, we applied a generative technique of XVCL (XML-based Variant Configuration Language) to represent similar classes and methods in generic, adaptable form. Concrete buffer classes could be automatically produced from the generic structures. We argue, on analytical and empirical grounds, that unifying clones reduced conceptual complexity and enhanced the changeability of the Buffer library at rates proportional to code size reduction (68%). We evaluated our solution in qualitative and quantitative ways, and conducted a controlled experiment to support this claim. The approach presented in the paper can be used to enhance genericity and changeability of any program, independently of an application domain or programming language. As the solution is not without pitfalls, we discuss trade-offs involved in its project application. Copyright © 2006 John Wiley & Sons, Ltd.

[1]  Don S. Batory,et al.  Scaling step-wise refinement , 2004, IEEE Transactions on Software Engineering.

[2]  Andrew Kennedy,et al.  Design and implementation of generics for the .NET Common language runtime , 2001, PLDI '01.

[3]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[4]  Gregor Kiczales,et al.  Aspect-oriented programming , 1996, CSUR.

[5]  S. Tucker Taft,et al.  Ada 95 Reference Manual , 1995, Lecture Notes in Computer Science.

[6]  Ted J. Biggerstaff,et al.  The library scaling problem and the limits of concrete component reuse , 1994, Proceedings of 1994 3rd International Conference on Software Reuse.

[7]  Jaakko Järvi,et al.  A comparative study of language support for generic programming , 2003, OOPSLA '03.

[8]  P. Bassctt Framing software reuse - lessons from real world , 1997 .

[9]  Martin Fowler,et al.  Analysis patterns - reusable object models , 1996, Addison-Wesley series in object-oriented software engineering.

[10]  Martin Fowler,et al.  Refactoring - Improving the Design of Existing Code , 1999, Addison Wesley object technology series.

[11]  Stan Jarzabek,et al.  Industrial experience with building a web portal product line using a lightweight, reactive approach , 2005, ESEC/FSE-13.

[12]  Stan Jarzabek,et al.  XVCL Approach to Separating Concerns in Product Family Assets , 2001, GCSE.

[13]  James R. Cordy,et al.  Comprehending reality - practical barriers to industrial adoption of software maintenance automation , 2003, 11th IEEE International Workshop on Program Comprehension, 2003..

[14]  Stan Jarzabek,et al.  Detecting higher-level similarity patterns in programs , 2005, ESEC/FSE-13.

[15]  Stanley M. Sutton,et al.  N degrees of separation: multi-dimensional separation of concerns , 1999, Proceedings of the 1999 International Conference on Software Engineering (IEEE Cat. No.99CB37002).

[16]  Don S. Batory,et al.  The design and implementation of hierarchical software systems with reusable components , 1992, TSEM.

[17]  S. Tucker Taft,et al.  Consolidated Ada Reference Manual Language and Standard Libraries , 2002, Lecture Notes in Computer Science.

[18]  Damith C. Rajapakse,et al.  Beyond templates: a study of clones in the STL and some general implications , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[19]  Yang Jun,et al.  Applying a generative technique for enhanced genericity and maintainability on the J2EE platform , 2005, GPCE'05.

[20]  Don S. Batory,et al.  Scalable software libraries , 1993, SIGSOFT '93.

[21]  Stéphane Ducasse,et al.  A language independent approach for detecting duplicated code , 1999, Proceedings IEEE International Conference on Software Maintenance - 1999 (ICSM'99). 'Software Maintenance for Business Change' (Cat. No.99CB36360).

[22]  Weishan Zhang,et al.  XVCL: XML-based variant configuration language , 2003, 25th International Conference on Software Engineering, 2003. Proceedings..

[23]  Miryung Kim,et al.  An ethnographic study of copy and paste programming practices in OOPL , 2004, Proceedings. 2004 International Symposium on Empirical Software Engineering, 2004. ISESE '04..

[24]  Weishan Zhang,et al.  Supporting Product Line Evolution with Framed Aspects , 2004 .

[25]  Stan Jarzabek,et al.  Eliminating redundancies with a "composition with adaptation" meta-programming technique , 2003, ESEC/FSE-11.

[26]  Krzysztof Czarnecki,et al.  Generative programming - methods, tools and applications , 2000 .

[27]  Kostas Kontogiannis,et al.  Evaluation experiments on the detection of programming patterns using software metrics , 1997, Proceedings of the Fourth Working Conference on Reverse Engineering.

[28]  David R. Musser,et al.  STL tutorial and reference guide , 2001 .

[29]  Joseph A. Goguen,et al.  Parameterized Programming , 1984, IEEE Transactions on Software Engineering.

[30]  David R. Musser,et al.  STL tutorial and reference guide, second edition: C++ programming with the standard template library , 2001 .

[31]  James R. Cordy Comprehending Reality: Practical Challenges to Software Maintenance Automation , 2003 .

[32]  William F. Smyth,et al.  Computing Patterns in Strings , 2003 .

[33]  Cristina V. Lopes,et al.  Aspect-oriented programming , 1999, ECOOP Workshops.

[34]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[35]  David R. Musser,et al.  STL tutorial and reference guide - C++ programming with the standard template library , 1996, Addison-Wesley professional computing series.

[36]  Shinji Kusumoto,et al.  CCFinder: A Multilinguistic Token-Based Code Clone Detection System for Large Scale Source Code , 2002, IEEE Trans. Software Eng..