Philosophy behind empty CompoundCommands? [message #514557] |
Mon, 15 February 2010 13:39  |
Eclipse User |
|
|
|
Dear EMF folks,
I do not understand the philosophy behind CompoundCommands in EMF,
especially their behavior when they are empty. Maybe someone could
enlighten me?
An empty CompoundCommand will not prepare, is not executable and
unwrap() will result an UnexecutableCommand. I think this is quite odd;
I would expect it would still be able to execute but do nothing.
The effect is quite severe, as an empty CompoundCommand will let a
transaction fail or put into another CompoundCommand the latter will
also be unexecutable:
CompoundCommand c1 = new CompoundCommand();
....
CompoundCommand c2 = new CompoundCommand();
if(condition)
c2.append(someOtherCommand);
c1.append(c2.unwrap());
The scheme around c2 is explicitly encouraged by the Javadoc of the
unwrap() method. Here the executable state of c1 depends on the
condition that should only influence c2. Is this really desired
behavior? Am I using these CompoundCommands maybe in a strange way?
It's like appending an empty String to a String or an Empty List to a
List. I would expect the original item to be unchanged of such action...
Cheers,
Hauke
|
|
|
Re: Philosophy behind empty CompoundCommands? [message #514606 is a reply to message #514557] |
Mon, 15 February 2010 17:45  |
Eclipse User |
|
|
|
Hauke,
A no-op command on the command stack would be kind of pointless. In any
case, even if the design is less than idea, after eight years being that
way, it's not something that ought to be changed.
Hauke Fuhrmann wrote:
> Dear EMF folks,
>
> I do not understand the philosophy behind CompoundCommands in EMF,
> especially their behavior when they are empty. Maybe someone could
> enlighten me?
>
> An empty CompoundCommand will not prepare, is not executable and
> unwrap() will result an UnexecutableCommand. I think this is quite
> odd; I would expect it would still be able to execute but do nothing.
>
> The effect is quite severe, as an empty CompoundCommand will let a
> transaction fail or put into another CompoundCommand the latter will
> also be unexecutable:
>
> CompoundCommand c1 = new CompoundCommand();
> ...
> CompoundCommand c2 = new CompoundCommand();
> if(condition)
> c2.append(someOtherCommand);
> c1.append(c2.unwrap());
>
>
> The scheme around c2 is explicitly encouraged by the Javadoc of the
> unwrap() method. Here the executable state of c1 depends on the
> condition that should only influence c2. Is this really desired
> behavior? Am I using these CompoundCommands maybe in a strange way?
>
> It's like appending an empty String to a String or an Empty List to a
> List. I would expect the original item to be unchanged of such action...
>
> Cheers,
> Hauke
|
|
|
Powered by
FUDForum. Page generated in 1.07616 seconds