I'm struggling with understanding the point of the Receiver in the Command Pattern. I have a small example, and I'm hoping someone can explain what the receiver is and why I need it.
ICommand - All my commands will implement this. Contains the execute() method.
LsCommand - Wraps the Linux shell to prevent the developers from using the LS command, and implements the ICommand. (This is just an example. I know there is going to be someone that asks why...)
MyQueue (Invoker) - ICommands get added to this, and are ran at a later time by using the ICommand.execute().
Why do I need a Receiver if my LsCommand can contain the logic for the command? Is the receiver the linux shell? Is the point of the Receiver for me to be able to pass in different types of end points?
Aucun commentaire:
Enregistrer un commentaire