Le pattern Command encapsule une requête comme un objet — transformant une action en un objet autonome avec toutes ses informations. Cela permet la mise en file d'attente, la journalisation, l'annulation/refonte, et le découplage entre le demandeur et l'exécuteur.
Qu'est-ce que le pattern Command fait
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
