Command pattern ایک درخواست کو ایک object کے طور پر محفوظ کرتا ہے — ایک عمل کو ایک خود مختار object میں تبدیل کرتا ہے جس میں اس کی تمام معلومات ہو۔ یہ queuing، logging، undo/redo، اور درخواست کار کو executor سے الگ کرنے کو ممکن بناتا ہے۔
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
