Parameterise Method
From CSSEMediaWiki
(Difference between revisions)
Brett Ward (Talk | contribs) (Page Outline Added) |
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward) |
(One intermediate revision by one user not shown) |
Latest revision as of 03:18, 25 November 2010
If methods are essentially the same but the values contained within the methods are different, they should be turned into a single method that uses a parameter to define these values.
A common example would be something like taxes. Methods may be made representing the tax brackets (eg applyTaxCodeM(), applyTaxCodeML()) but this produces duplicated code and would more easily be refactored into one method (applyTax(amount))
See Also: