Home | Issues | Profile | History | Submission | Review
Vol: 60(74) No: 2 / June 2015        

Correction of Switch Statements using Complex Design Restructurings
Ioana Verebi
Politehnica University of Timisoara, Faculty of Automation and Computer Science, Timisoara, Romania, e-mail: ioana.verebi@gmail.com
George Ganea
Politehnica University of Timisoara, Faculty of Automation and Computer Science, Timisoara, Romania, e-mail: george.ganea@gmail.com


Keywords: refactoring, Eclipse plugin, high-level transformation, correction strategy

Abstract
The use of an object-oriented language does not guarantee the use of object-oriented design principles. A common problem is that programmers who do not fully understand the principles of the object-oriented paradigm use conditional statements to simulate a two dimensional hierarchy in a single dimensional space. Problems like this occur also when a system has been modified repeatedly to accommodate changes or when we deal with legacy systems. We propose a solution for identifying and automatically correcting problematic switch statements. Our article lays out the approach of correcting these flawed codefragments using four strategies: Replace Type Code with Subclasses, Replace Conditional with Polymorphism, Replace State-Altering Conditionals with State and Replace Conditional Logic with Strategy. The novelty consists in approaching these restructurings as a composition of elementary code transformations, thus increasing the potential for reuse and customisation. In support of our approach, we implemented a tool, named reFactor, which automatically detects and corrects flawed switchstatements. The first section of our paper presents the need for such tools, while section II presents related research in the area of automated design flaw correction. Section III and IV lay out our approach, presenting the basic building blocks of our platform and the novel suite of elementary code transformations which are composed into high-level restructurings. Section V presents the validation for our work, while section VI concludes this paper

References
G. Booch, Object-Oriented Analysis and Design with Applications, 2nd ed. Redwood City: Benjamin Cummings, 1994.
[2]K. Beck, Extreme Programming Explained: Embrace Change. Addison- Wesley, 1999.
[3]W. W.Royce, “Managing the development of large software systems,” in Tutorial: Software Engineering Project Management, R. Thayer, Ed. Washington: IEEE Computer Society, 1987, pp. 118–127.
[4]M. Lehman and L. Belady, Program Evolution: Processes of Software Change. London: Academic Press, 1985. [Online]. Available: ftp://ftp.umh.ac.be/pub/ftpinfofs/1985/ProgramEvolution.pdf.
[5]D. L. Parnas, “Software aging,” in Proceedings of 16th International Conference on Software Engineering (ICSE ’94). Los Alamitos CA: IEEE Computer Society, 1994, pp. 279–287.
[6]K. Bennett, “Legacy systems: Coping with success,” IEEE Softw.,vol. 12, no. 1, pp. 19–23, 1995.
[7]M. Fowler, K. Beck, J. Brant, W. Opdyke, and D. Roberts, Refactoring: Improving the Design of Existing Code. Addison Wesley, 1999.
[8]W. F. Opdyke, “Refactoring object-oriented frameworks,” Ph.D. thesis, University of Illinois, 1992.
[9]O. Ciupke, “Automatic Detection of Design Problems in Object-Oriented Reengineering,” in Technology of Object-Oriented Languages and Systems - TOOLS 30, IEEE Computer Press, 1999.
[10]R. Marinescu, “Measurement and quality in object-oriented design,” Ph.D. thesis, Politehnica University of Timisoara, 2002.
[11]“incode, online athttp://www.intooitus.com/incode.html.”
[12]D. B. Roberts, “Practical analysis for refactoring,” Ph.D. thesis, University of Illinois,1999.
[13]J. Kerievsky, Refactoring to Patterns. Addison Wesley, 2004.
.[14]D. Roberts, J. Brant, and R. Johnson, “A refactoring tool forsmalltalk,” Theor. Pract. Object Syst., vol. 3, no. 4, pp. 253–263, 1997.
[15]M. Vittek, “Refactoring browser with preprocessor,” in Software Maintenance and Reengineering, 2003. Proceedings. Seventh European Conference on, Mar. 2003, pp. 101–110.
[16]I. Moore, “Automatic Inheritance Hierarchy Restructuring and Method Refactoring,” in Proceedings of OOPSLA ’96 (11th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications).ACM Press, 1996, pp.235–250.
[17]S. Negara, N. Chen, M. Vakilian, R. E. Johnson, and D. Dig, “Acomparative study of manual and automated refactorings,” in Proceedings of the 27th European Conference on Object-Oriented Programming, ser. ECOOP’13. Berlin, Heidelberg: Springer-Verlag, 2013, pp.552–576.[Online].Available:http://dx.doi.org/10.1007/978-3-642-39038-823.
[18]F. Simon, F. Steinbruckner, and C. Lewerentz, “Metrics based refactoring,” in CSMR ’01: Proceedings of the Fifth European Conferenceon Software Maintenance and Reengineering. Washington, DC, USA: IEEE Computer Society, 2001, p. 30.
[19]Y. Kataoka, M. D. Ernst, W. G. Griswold, and D. Notkin, “Automated support for program refactoring using invariants,” in Proceedings of the International Conference on Software Maintenance, (Florence, Italy), Nov. 2001, pp. 736–743.
[20]“http://www.jdeodorant.com/.”
[21]M. O. Cinneide and P. Nixon, “A methodology for the automated introduction of design patterns,” in Proceedings ICSM’99. IEEE Computer Society Press, Aug. 1999.
[22]A. Trifu, “Towards automated restructuring of object oriented systems,” Ph.D. thesis, Universitat Karlsruhe, 2008.
[23]E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994.