Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Upcase Refactoring Trail

Replace Variable with Query

Refactoring exercise using the Replace Temp with Query refactoring for the Upcase Refactoring Trail.

Replace Temp with Query

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

Before

classTipper
...
deftotaltax_amount=amount * TAXdiscount_amount=amount * (discount_percentage / 100.0)tip_amount=amount * (tip_percentage / 100.0)amount + tax_amount - discount_amount + tip_amountendend

After

classTipper
...
deftotalamount + tax_amount - discount_amount + tip_amountendprivatedeftax_amountamount * TAXenddefdiscount_amountamount * (discount_percentage / 100.0)enddeftip_amountamount * (tip_percentage / 100.0)endend

Additional Resources

About

Replace Temp with Query refactoring

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages