Code Refactoring using design patterns


by Yassine Al Harek
Supervised by Dr. hab. inż. Anna Fabijańska, Prof. PŁ

Introduction


This thesis focuses on software maintenance, and more precisely the state-of-art of automatic detection and refactoring solutions. This work intends to plant a seed of a robust solution automating the process of code smells detection and their transformation into a more readable and reusable code while profiting from the advantages of design patterns.


2/10

State of art

Prechlet et al.(2001) put the popular idea of preferring design patterns to simpler Object-Oriented solutions to test.
Demeyer (2005) tested the effect of virtual function in C++ on program efficiency, and whether the idea that polymorphism improves maintainability on detriment
of performance, is a valid one.
Tsantalis and Chatzigeorgiou (2010) proposed an algorithm to extract refactoring suggestions to the Type-checking code smell and eventually propose an application of the refactoring.
3/10

Problem statements



  • Principles of Object-Oriented Paradigm are frequently dismissed.
  • The process of refactoring is costly.
  • The Netbeans Platform has a lack of refactoring tools.
  • The existing solutions do not propose automatic refactoring.
  • The existing solutions do not profit from the advantages of design patterns.

4/10

Proposed solution



A Netbeans plugin that detect code smells and suggests an automatic refactoring. As a commencement, the Type-checking code smell was covered. The tool detect the smell based on the criteria established by Tsantalis et Chatzigeorgiou. Then, a refactoring to a Strategy Pattern is conducted.



5/10

The code smell AST


6/10

sample








launching the detection
      C hange made to the class containing the code smell












7/10
 

sample(2)















8/10

Future Work



  • Cover remaining code smells
  • Improve the detection efficiency, i.e. reducing "false positives".
  • Provide a visualisation (UML diagrams, among others) of changes made.
  • Create a database of accepted refactoring by users



9/10
 

Conclusion














10/10

Master defence

By Yassine Al Harek

Master defence

  • 593