Introduce Parameter Object
From CSSEMediaWiki
(Difference between revisions)
Brett Ward (Talk | contribs) |
Jenny Harlow (Talk | contribs) (merge with 'replace parameter object', add ref to long parameter list smell) |
||
Line 1: | Line 1: | ||
− | What to do when you have a group of parameters that naturally relate or fit together. This will help make parameter lists easier to understand and will make it easier to modify if needed. | + | What to do when you have a group of parameters that naturally relate or fit together. This will help make parameter lists shorter and easier to understand ([[Long parameter list smell|long parameter list smell]]) and will make it easier to modify if needed. |
It can also help reduce [[Duplicate code smell]] by moving other behaviour to this new object | It can also help reduce [[Duplicate code smell]] by moving other behaviour to this new object | ||
Line 16: | Line 16: | ||
== See Also == | == See Also == | ||
+ | *[[Data_class_smell|Data class smell]] | ||
{{Refactoring}} | {{Refactoring}} |
Latest revision as of 04:06, 19 October 2010
What to do when you have a group of parameters that naturally relate or fit together. This will help make parameter lists shorter and easier to understand (long parameter list smell) and will make it easier to modify if needed.
It can also help reduce Duplicate code smell by moving other behaviour to this new object
Example:
amountInvoicedIn(Date start, Date end)
becomes
amountInvoicedIn(DataRange range)
with DataRange becoming the new "Parameter Object"
See Also