is a pattern from
's Arguments and Results paper.
calls this pattern "
" in his book
It kind of goes like this. You have a method which has too many arguments. Make a little
which bundles them and pass it to the method.
Why do this? Well, if you can come up with a good name for the
, it may make your code clearer. You can also reuse the
if you have several calls to the same method with almost but not quite the same values (
). If the attributes of the
have good defaults, you may not have to set them all. Another option is to have a few canned
s hanging around that you can pass to the method when you need to. You might even move some behaviour into the
, because of a
If you like compact, dynamic code, use an associative array.
Or for extra code-cleaning power, try the
View edit of
March 13, 2010
with title or text search