Description
High quality software systems go through several changes in their life cycle. Like an automobile, a software system needs regular maintenance at appropriate times. Refactoring is the industry-wide accepted software-servicing methodology. Refactoring makes the software highly malleable, extensible, reusable and reliable; however, there are no systematic approaches to refactoring. This makes refactoring a difficult and time-consuming process for even seasoned developers. For more complex systems, it is an even harder and riskier proposition. Due to this, many developers trade refactoring for increased software features. This short-term approach makes it difficult to maintain the software and hastens the sunset of the software system. In this Thesis, a systematic approach to refactoring a Java-based software system is proposed. Industry-accepted GOF (Gang of Four) design patterns are used to refactor the code. Once a systematic approach is defined, it is very easy to automate the entire refactoring of the code. The proposed approach is to parse the java source code using an IJACC parser and then build an abstract parse tree (APT). From the APT, refactorable events (RE) are captured. These events are compared against the Design Pattern Knowledge Base (DPKB). If there is a match, a respective design pattern name, RE and source code is passed to an Automatic Transformation (AT) tool to do the final refactoring. The distinguishing feature of our approach is that the refactored code-class structure hierarchy is maintained as closely as possible to the original code. We have taken a simple design pattern (Singleton) and a complex (Command) pattern as a case study to prove our approach is robust and meets the developer's expectations.