Refactoring exercise using the Replace Temp with Query refactoring for the Upcase Refactoring Trail.
Extract the expression into a method. Replace all references to the temp with the expression. The new method can then be used in other methods. -- Martin Fowler
classTipper
...
deftotaltax_amount=amount * TAXdiscount_amount=amount * (discount_percentage / 100.0)tip_amount=amount * (tip_percentage / 100.0)amount + tax_amount - discount_amount + tip_amountendendclassTipper
...
deftotalamount + tax_amount - discount_amount + tip_amountendprivatedeftax_amountamount * TAXenddefdiscount_amountamount * (discount_percentage / 100.0)enddeftip_amountamount * (tip_percentage / 100.0)endend