You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ola Berg <ol...@arkitema.se> on 2002/08/09 09:27:23 UTC

RE: [pattern] Command or Closure [was ThrowableHandler]

http://www.owlnet.rice.edu/~comp212/99-spring/Tutorials/12/):
>>This idea of wrapping a function up in an object is called the command
>pattern, and the wrapped-up function is called the command. Sometimes the
>object itself is called a closure. Don\'t worry about the terminology if you
>haven\'t heard it before; just think \"command object\" when you hear
>\"closure.\"

Martin Cooper:
>So they\'re not quite the same thing. So if a \'command\' is a function/method
>and a \'closure\' is an object, I don\'t know what we call the interface. ;-)

I believe the opposite, that when the text says \"the object in itself\", it is refering to an instance of the command object (an object implementing the Op interface), so they _are_ the same thing, a command (like ToStringOp in the text) is a method/function wrapped up in an object.

But on the other hand, the text says: \"<em>Sometimes</em> the object is called closure\" (my emphasis), which would indicate that \"closure\" is a term less used. Personally, I believe that Command is more widely understood than Closure, and that ObjectHandler is the most descriptive name of them all.

My initial question in this matter was whether a Command and an ObjectHandler was the same thing, and I now propose that Command (or Closure) indicates a specific _use_ of an ObjectHandler. But I don\'t mind (any longer) if the terms are used interchangeably, it is just that I think ObjectHandler is more widely understood, and that one could hint of its usage in the command pattern (as a \"closure\" :-) in the docs.

Now, next question: my ObjectHandler\'s handle() method didn\'t have a return value, and neither has Command in [pattern]. But shouldn\'t it? Isn\'t necessary if one wants to implement the Command pattern with it? And a remark in the docs that if void methods are to be wrapped up in Command, the method should return null (or wild thought: java.lang.Void.TYPE)

/O


--------------------
ola.berg@arkitema.se
0733 - 99 99 17

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>