1.Topics‎ > ‎Architecture‎ > ‎Patterns‎ > ‎a.Design Patterns‎ > ‎D.Behavioral Patterns‎ > ‎

Command Pattern

  1. Summary
    1. Encapsulate a request in an object and allows the parameterization of clients with different requests and optionally saves the requests in a queue. 
  2. Overview Tutorials 
    1. http://www.oodesign.com/command-pattern.html
  3. Types
    1. Simple Command Pattern
      1.  Client Encapsulate the command object and invoke ICommand.Execute() funtions and command return final outcome to client.
    2. Invoker based command Pattern
      1. Client creates a concrete command and pushes it to invoker.
      2.  Invoker call execute function of command that activate Receiver (Target Object on which command need to work on)
      3.  Once done command return a final outcome to client via invoker.
    3. Distributed (Queued) Command Pattern
  4. Specific Considerations
    1. Invoker and Chain of responsibility
      1. Both work with a request object  however command pattern works only at receiver end and can be used in conjuction.
  5. Advantage
    1.  The main advantage of the command design pattern is that it decouples the object that invokes the operation from the one that know how to perform it.
    2. The invoker should be aware only about the abstract command class.
    3. Client can also work as invoker in simple scenario.