The Command Design Pattern is a behavioral design pattern that encapsulates a request as an object, thereby allowing parameterization of clients with queues, requests, and operations. This pattern decouples sender and receiver of a request based on a command, which helps in invoking the right method at the right time without knowing the actual implementation details.
Components of Command Design Pattern
- Command: Defines an interface for executing an operation.
- Concrete Command: Implements the Command interface and binds a receiver with an action. It defines a binding between the action and the receiver.
- Invoker: Requests the command to execute the operation.
- Receiver: Knows how to perform the operation.