[
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
 
 
  
  
  
  
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