[patterns-discussion] About the Collecting Parameter pattern
Arno Haase
Arno.Haase at haase-consulting.com
Mon Apr 18 00:39:10 CDT 2005
Hi,
this pattern solves the problem of how a series of operations can all
contribute to a collection of results. You could of course have the
operations return a collection and accumulate the results in the loop
that calls them, but in e.g. Java methods can have only one return value
and that may be "in use" for other things.
A typical use is the gathering of messages, especially error messages.
The return value of the operations is often in use for the actual
"business" part of the operations, and the use of exceptions would mean
that every operation can contribute at most one message.
Therefore: pass a collection to each operation so that it can contribute
all the messages. This parameter "collects" the messages, hence the name
of the pattern. It is useful e.g. for collecting messages to be
displayed in a UI.
It is documented in Kent Beck's "Smalltalk Best Practices" book, wich
contains a lot of very helpful patterns that are applicable to other
languages as well.
- Arno
Jesús Alonso wrote:
> Hello.
>
> I need information about the Collecting Parameter design pattern, but
> all I could find was the info in this page:
> http://c2.com/cgi/wiki?CollectingParameter
>
> The fact is that the information given there about the pattern isn't
> enough for me to understand very well the pattern.
> I would find helpful any information about what this pattern does
> exactly, some examples, and maybe a concrete context where it could be
> applied successfully and why.
>
> Thanks in advance.
>
> Best regards,
> Jesús Alonso
>
>
> _______________________________________________
> patterns-discussion mailing list
> patterns-discussion at cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/patterns-discussion
>
More information about the patterns-discussion
mailing list