Implementation of refactoring tool
DPT(Design Pattern Transformer) is a tool for automatic transformation of the source code for programs written in object-oriented languages. Currently it works only for the Java(1.1), but it can be extended to transform C++ programs or to support high-level source transformations like C++ to Java or C to C++.
5.1 Introduction of DPT
Our goal was to create a small, useful tool which can be used intuitively, without a complex startup - procedure. We tried to design the tool to be extremely user-friendly. In this chapter would like differentiate the introduction of the tool-properties and introduction of specific transformation-properties of the DPT.
5.1.1 Tool features
1) The user doesn't need to include all source-files of his software in a DPT-project. It is enough to include just a part of source which will be transformed or will be required as a parameter of the transformation. (Example: super-class for a class, if class-method will be deleted) Additional files can be included any time in the DPT-project.
2) DPT-works with a copy of source-files(working copy). The source-files will be unchanged until the user explicitly saves(commit) the changes.
3) It is possible to modify source files simultaneously with DPT-project(for example, in user’s common development tool). DPT keeps all files up to date and asks the user to synchronize the source or skip the changes if project files were modified outside of the DPT-environment.
4) DPT offers a mechanism to „undo“ / “redo“ a transformation after the transformation was successful completed and the user already saved the modified files.(Except for the transformations which create new source-files, like „CreateClass“)
5) DPT offers many additional features which the user may expect from a program development tool. Those features are:
- Class browser
- Force reparse
- Synchronize source
- Remove generated comments
- GoToLine - dialog
5.1.2 Transformation features
1) DPT offers several catalogs of transformations which can be applied to the project. The user can also define his own (favorite) catalog and load/use it in the project. Transformations which are included into a catalog are ordered by specific design pattern, for example, „class“ (move/delete/...), „inherit“(generalize/specialize...) At the moment (Version 1.1) over 40 transformation are available and can be used for the creation of new composed transformations(see below).
(Figure 5.1 GUI: Loading catalog)
2) The user can also create his own transformations as a composition of existing ones. The user can at any time browse the composition of his transformation. A composed transformation can be modified by „add/remove“ components of the transformation.
(Figure 5.2 GUI: Loading transformation)
Example (for an extension of composite-transformation):
Description: Transformation creates an instance-variable of type = interface and
initialized this member with a concrete constructor.
Composition: Transformation1= Create variable, transformation2= Substitute variable
Extension: Access-methods have to be created (Get/Set)
The user just need to load composed transformation and add new operation (“VariableAccess“)
3) One of the most important tasks during the transformation is setting of parameters. The user shouldn’t have to type long file-paths or remember method-names, open and close the files or make sure that the symbol does not already exist. This should be done automatically. DPT provides a high-level of abstraction for this task. The „DPT-Parameter Assistant“ offers a navigational access to the required parameter by using information of the programs symbol-table. This method saves a lot of interaction with the user. This saves time for typing and avoid the errors.
4) DPT offers a history list of all transformations which were completed in this project.
!-- *** -->