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 ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.