Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 2.24 KB

File metadata and controls

39 lines (32 loc) · 2.24 KB

Command — where it lives outside this repo

Cited, real implementations to study (or point an agent at) when designing or reviewing command-shaped code.

Python standard library

Major ecosystems

  • Django migration operations. Each operation implements database_forwards and database_backwards — execute plus undo — and the migration executor is an invoker replaying them in order, either way. docs.djangoproject.com/en/stable/ref/migration-operations/
  • Qt's QUndoCommand / QUndoStack (exposed by PyQt/PySide) — the canonical GUI undo architecture: commands with redo()/undo(), an invoker stack with exactly the clear-redo-on-push contract this module's UndoStack implements. doc.qt.io/qt-6/qundocommand.html (unverified)
  • Celery tasks. A task invocation serialized onto a broker queue is the pattern at distributed scale: the worker (invoker) executes requests it never saw created. docs.celeryq.dev (unverified)

What to notice across all of them

The dividing line is always the same: plain callables until requests need to be stored, inspected, or reversed, objects after. Django's migrations and Qt's undo stack both pay the class-per-operation cost precisely because they need the backwards direction — and neither uses a command class where a forward-only callback would do.