diff --git a/Command/CommandInterface.php b/Command/CommandInterface.php index 8fe9c5b..ebdbb85 100644 --- a/Command/CommandInterface.php +++ b/Command/CommandInterface.php @@ -3,25 +3,7 @@ namespace DesignPatterns\Command; /** - * Command pattern - * - * Purpose: To encapsulate invocation and decoupling - * - * We have an Invoker and a Receiver. This pattern use a "Command" to delegate the - * method call against the Receiver and presents the same method "execute". - * Therefore, the Invoker just know to call "execute" to process the Command of - * the client. The Receiver is decoupled from the Invoker - * - * The second aspect of ths pattern is the undo(), which undoes the method execute() - * Command can also be agregated to combine more complex commands with minimum - * copy-paste and relying on composition over inheritance. - * - * Examples: - * - A text editor : all events are Command which can be undone, stacked and saved. - * - Symfony2: SF2 Commands that can be run from the CLI are built with just the Command pattern in mind - * - big CLI tools use subcommands to distribute various tasks and pack them in "modules", each of these - * can be implemented with the Command pattern (e.g. vagrant) - * + * class CommandInterface */ interface CommandInterface { diff --git a/Command/README.md b/Command/README.md new file mode 100644 index 0000000..4797c8e --- /dev/null +++ b/Command/README.md @@ -0,0 +1,17 @@ +# Command + +## Purpose + +To encapsulate invocation and decoupling. + +We have an Invoker and a Receiver. This pattern use a "Command" to delegate the method call against the Receiver and presents the same method "execute". +Therefore, the Invoker just knows to call "execute" to process the Command of the client. The Receiver is decoupled from the Invoker. + +The second aspect of ths pattern is the undo(), which undoes the method execute(). +Command can also be aggregated to combine more complex commands with minimum copy-paste and relying on composition over inheritance. + +## Examples + +* A text editor : all events are Command which can be undone, stacked and saved. +* Symfony2: SF2 Commands that can be run from the CLI are built with just the Command pattern in mind +* big CLI tools use subcommands to distribute various tasks and pack them in "modules", each of these can be implemented with the Command pattern (e.g. vagrant)