Inline Temporary Variable

The Inline temporary variable refactor allows you to remove temporary variables from your code and replace them with actual code expressions assigned to the temporary variable. Think of this as the opposite of Introduce Local. For example, Figure 9.13 shows how you can turn the discount variable back into inline code.

Image

FIGURE 9.13 Use the Inline temporary variable to turn temporary variables into inline code.

The result of this Refactor operation is the removal of the temporary variable. The use of the temporary variable is then replaced by inline code, as the following shows.

//apply discount rule
if (total > discountThreshold)
{
    total = total - total * discountPercent;
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset