Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-ui-dev] Difference between Action and Command

Glad you asked...
 
I always considered an "action" as something attached to the user interface that responds to user interaction, while a "command" is an object that encapsulates a discrete change against the model.
 
Generally, the two work together quite nicely; a single instance of an action is attached to a component like a menu or assigned to a keypress, and that action will create instances of commands and run them.
 
I haven't created many eclipse "actions", but it feels pretty consistent with the above to me.
 
 
I just skimmed the "Contexts" prop page, and I'm a bit concerned that it's merging the two above (and quite distinct) concepts. At its most basic, an "action" would just be a "command factory", simply creating an instance of a command. For these types of commands, the "Contexts" prop would work fine, as it's just eliminating the middle-man action.
 
[NOTE: Please let me know if I misinterpreted, as I only skimmed it rather quickly]
 
However, consider two things: overhead of command object creation, and inflexibility.
 
First, taking this approach, a new command instance would need to be created for each user interaction. While in many cases this is what we need, as the object needs to be put on the undo stack, there are plenty of actions that don't need to be "undoable", such as "find" (arguable..., but get my drift?)
 
Second, and more importantly, is inflexibility. While many actions would simply be "command factories", I don't think that can be said for all actions. I tend to view command objects as acting against a single model; an action may need to affect multiple models. While we could create a composite command that encapsulates a multi-model update (with separate commands for each), that forces us into a specific strategy for "undo".
 
Granted, there may not be many apps that need the extra flexibility, but it should be there IMHO. We can create a simple "command factory" action that can be used all over the place to create certain instances of commands (and perhaps the "binding" mentioned in the contexts prop could be implemented using this), but I think we should still leave it open that an action can be bound as well, only creating the single instance of the action object that can create commands or perform other tasks.
 
Don't get me wrong -- I really like commands. I just feel this prop is merging two concepts that should remain independent, but encouraged to be used together.
 
-- Scott
 
==============================================================
Scott Stanchfield    scott@xxxxxxxxxxxx    http://javadude.com
 
I haven't gotten *any* spam since joining http://knowspam.net!
 
Lead author of "Effective VisualAge for Java, Version 3"
                                      http://javadude.com/evaj
Visit for Java Enlightenment!             http://www.jguru.com
==============================================================
 



From: platform-ui-dev-admin@xxxxxxxxxxx [mailto:platform-ui-dev-admin@xxxxxxxxxxx] On Behalf Of Randy Hudson
Sent: Wednesday, August 06, 2003 1:21 PM
To: platform-ui-dev@xxxxxxxxxxx


In the recently announced "contexts" proposal:
"As Eclipse moves from an action-centric model to command-centric model, action sets would disappear entirely"

To me "action" and "command" are the same thing.  What is the difference here between a command and an action?  Where can I read more on the new "command" stuff?
Won't this be confusing since the term "command" is widely used to mean a change which can be undone and redone?  There is also a bugzilla open tracking the proposal to add undo/redo to the workbench.

-Randy

Back to the top