[리팩토링 cheat sheet] 9.1 변수 쪼개기(Split Variable)
# Before

temp = 2 * (height + width)
print(temp)
temp = height * width
print(temp)
# After

PERIMETER = 2 * (height + width)
print(PERIMETER)
AREA = height * width
print(AREA)

# Before

def discount(input_value, quantity):
    if input_value > 50:
        input_value = input_value - 2
    if quantity > 100:
        input_value = input_value - 1
    return input_value
# After

def discount(original_input_value, quantity):
    result = original_input_value
    if input_value > 50:
        result -= 2
    if quantity > 100:
        result -= 1
    return result


첫번째 if 문에서, 입력 값에 기초하여 결과값을 누적해 계산한다는 사실을 더 명확히 드러낸다.