Refactoring is a technique for improving the design of existing code by applying a number of defined code-level transformations to address identified software design flaws. Refactoring has a significant role to play in software development by increasing the flexibility of an existing design to accommodate the next stage of design or a maintenance change. A key challenge in the refactoring process is the identification of the points at which these refactorings may be applied – the design flaws. Some are relatively easy to spot but the majority are concerned with subtle relationships between attributes of the code and are not easily identified. While human experience and intuition undoubtedly play a significant role in identifying these design flaws, searching for a large range of potential problems in a sizeable system is a daunting task that cries out for some form of automated support. The aim of this project was to investigate, evaluate and develop techniques for automatically detecting design flaws.
Software is by no means perfect, and software design is particularly difficult to get right. Like many designs, software is a balance between competing forces: functionality, flexibility, maintainability etc. There are a well-recognised set of problems that are commonly found in even the best software that may be indicative of deeper problems and therefore should be fixed - these are known as design flaws. However, these are described at a very abstract level and finding them within very large projects is time-consuming and difficult. The aim of this project was to be able to spot concrete instances of these high-level problems in software and bring them to the attention of the software engineer to address.
The primary outcome of the project was a software tool which automatically detects violations of encapsulation in software. The tool has been developed as a plug-in for the Eclipse IDE and uses heuristic descriptions of common design flaws such as data and god classes to detect areas of poor encapsulation within a system. The approach has been evaluated in a controlled study on two large open source systems which provided some valuable insights into the strengths and weaknesses of the approaches, mainly centred around the precise definition of design flaws and how this may be improved.