Refactoring: Refactorings/Inline Temp
Jump to navigation
Jump to search
Temporary variable is only used once and is a simple expression
Mechanics
- Find all references to the temp and replace them with the right-hand side of the assignment
- Test after each change
- Remove declaration and assignment of the temp
- Test
Example
Before
base_price = an_order.base_price
return (base_price > 1000)
After
return (an_order.base_price > 1000)