Programming with Castalia : Refactoring : Inline Temporary Variable
|
Previous
Top
Next
|
You have a local variable that is being assigned to a simple expression, and may be getting in the way of other refactorings.
Remove the variable, replacing all references to the variable with the original expression.
| function GetOrderPrice(ProductID, Quantity: Integer): Currency;
|
| BasePrice := GetProductBasePrice(ProductID);
|
| Result := BasePrice * Quantity;
|
| function GetOrderPrice(ProductID, Quantity: Integer): Currency;
|
| Result := GetProductBasePrice(ProductID) * Quantity;
|
This refactoring is the opposite of Introduce Explaining Variable.
To inline a variable, place the cursor in the name of the variable to be inlined, and invoke the Inline Temporary Variable refactoring. Castalia will remove the variable from the method, replacing all instances of the variable with the expression assigned to the variable.
See also: Refactoring Overview, Rename Local Variable Refactoring, Split Temporary Variable Refactoring