Programming with Castalia : Refactoring : Overview
Previous  Top  Next

What is refactoring?

"Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. It is a disciplined way to clean up code that minimizes the chances of introducing bugs. In essence when you refactor you are improving the design of the code after it has been written." (Martin Fowler in Refactoring: Improving the Design of Existing Code, Addison-Wesley 2000)

Castalia's Refactoring

Castalia's refactoring tools help to automate this process. In some instances, this amounts to a little more than a search-and-replace feature that understands Delphi code (such as Rename Class). In other cases, the refactoring requires complex semantic and structural analysis that results in improved code structure (i.e. Extract Method).

Castalia offers automated tools for the following refactorings:

Rename Local Variable - Changes the name of a local variable and all references to that variable within the procedure or function

Rename Parameter - Changes the name of a parameter in both interface and implementation declarations, and all references to the parameter within the procedure or function.

Inline Temporary Variable - Removes a local variable from code and replaces all references to that variable within the procedure or function with the expression assigned to the variable

Introduce Explaining Variable - Declares a new variable and initializes it to a specified expression.

Split Temporary Variable - Changes a variable that is assigned twice (without accumulation) into two distinct variables, each with a single assignment

Rename Method - Changes the name of a method and all calls to that method in the unit

Extract Method - Extracts a fragment of code into a new method with its own name, replacing the original fragment with a call to the new method

Add Parameter - Adds a new parameter to a procedure or function, synchronizing both the interface and implementation declarations of the method.

Surround With... - These are not true refactorings, but templates that allow you to surround existing code with common code constructs.

Rename Class - Changes the name of a class and all usages of the class name in the unit

Move Class - Moves a class (and all of its methods) from one unit to another











See Also: Configuring Refactoring