Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extend UndoableCommandInterface from CommandInterface #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ihor
Copy link
Contributor

@ihor ihor commented Jan 21, 2016

Hey guys,

I propose to extend UndoableCommandInterface from CommandInterface for the following reasons:

  1. It contains only undo method which doesn't look like command at all
  2. We can't correctly work this interface. Please look at these examples with simplified invokers:
function executeCommand(CommandInterface $command)
{
    $command->execute();
    $command->undo(); // undo is not part of the CommandInterface
}

function executeUndoableCommand(UndoableCommandInterface $command)
{
    $command->execute(); // execute is not part of UndoableCommandInterface
    $command->undo();
}

In both cases we can't follow the declared interface to work with the command.

Thanks,
Ihor

@domnikl
Copy link
Contributor

domnikl commented Jan 22, 2016

Looks good to me. What do you think about it @andrewnester?

@andrewnester
Copy link
Contributor

@domnikl yeah, looks good. Thanks @ihor !

domnikl pushed a commit that referenced this pull request Jan 22, 2016
Extend UndoableCommandInterface from CommandInterface
@domnikl domnikl merged commit 90fbff3 into DesignPatternsPHP:master Jan 22, 2016
@domnikl
Copy link
Contributor

domnikl commented Jan 22, 2016

Merged, thanks @ihor!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants