Parameterise Method
From CSSEMediaWiki
(Difference between revisions)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward) |
|||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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. | 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. | ||
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: