Programming with Castalia : Refactoring : Rename Local Variable
|
Previous
Top
Next
|
A local variable's name does not adequately describe the data represented by the variable.
Change the variable's name to something more appropriate.
| function CalculateAge(Birthday: TDateTime): Integer;
|
| I := Trunc(Now - Birthday);
|
| raise EUnderageCustomer.CreateFmt('Customer is only %d', [I]);
|
| function CalculateAge(Birthday: TDateTime): Integer;
|
| CustomerAge := Trunc(Now - Birthday);
|
| raise EUnderageCustomer.CreateFmt('Customer is only %d', [CustomerAge]);
|
To use Rename Local Variable, place the cursor in any instance the variable to be renamed and invoke Rename Local Variable from the Castalia Refactoring menu. Castalia will identify all instances of the variable and allow you to modify the name of the variable, propgating your changes to all instances of the variable. To finish, press Enter.
See Also: Refactoring Overview, Inline Temporary Variable Refactoring, Split Temporary Variable Refactoring