dimanche 16 février 2020

is it needed for using Command Pattern to use a "Command" interface, a "ReceiverCommand" class....?

Reading about the command pattern, dont we use it everyday partially without having to have a Command Interface, a ReceiverCommand class ....?. I mean, the commmand pattern is about to decouple the client from the commands within a class, right?

When you have a client who invokes these methods to start a pc:

  • pressPowerButton()
  • pressKey()
  • logIn()

You are coupling the client with these commands to start a pc because if you modify a method, add or delete you will have to modify the client who calls this method and the class which owns these methods, right?

But if you create a method which groups these operations like:

  • startPc

And from the client you call startPc(), are we not decoupling and then using partially the Command Pattern? Note: I know reading the Command pattern that the client is agnostic about the methods names to invoke

Thanks

Aucun commentaire:

Enregistrer un commentaire