Command pattern एक request को एक object के रूप में encapsulate करता है — एक action को उसकी सारी जानकारी के साथ एक स्वतंत्र object में बदल देता है। यह queuing, logging, undo/redo, और requester को executor से decouple करना सक्षम बनाता है।
Command pattern क्या करता है
COMMAND → encapsulate an action/request as an OBJECT (with its data and an execute method):
→ a command object knows WHAT to do and has the info to do it
→ the invoker triggers commands without knowing their details
→ decouples the object that INVOKES from the object that PERFORMS the action
→ "turn an action into an object" → store, pass, queue, log, undo it
