Replace Parameter with Explicit Methods
From CSSEMediaWiki
(Difference between revisions)
(New page: == Motivation == ''Refactoring'' Martin Fowler 1999 states that: "If a method can get a value that is passed in as a parameter by another means, it should." == Example == An object ...) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | This is used when you have a method which switches it's functionality based on a passed in parameter. | |
− | + | ==Steps== | |
+ | * Create a new method for each case | ||
+ | * Replace all calls to the old method with a call to the relevant new one | ||
+ | * Delete the old method | ||
− | == | + | ==References== |
− | + | * [http://sourcemaking.com/refactoring/replace-parameter-with-explicit-methods] | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 12:29, 26 September 2009
This is used when you have a method which switches it's functionality based on a passed in parameter.
Steps
- Create a new method for each case
- Replace all calls to the old method with a call to the relevant new one
- Delete the old method