Command pattern ห่อหุ้ม คำขอ (request) ให้เป็นออบเจ็กต์ โดยเปลี่ยนการกระทำให้เป็นออบเจ็กต์ที่เป็นอิสระพร้อมข้อมูลทั้งหมดของมัน สิ่งนี้ช่วยให้ทำ queuing, logging, undo/redo และลดการผูกติดระหว่างผู้ร้องขอกับผู้ดำเนินการได้
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
