Mรณdulo 27 ยท Design Patterns (All 23 GoF) โ Lecciรณn 14 de 23 ยท ~6 min
Command
Package a request as an object
Command turns a request into a standalone object with an execute method, so you can queue it, log it, retry it, or undo it. Background jobs are the perfect fit: each job is a command; a runner just calls each one.
In Python any callable is already a command โ a function, a lambda, or an object with __call__. The pattern earns its keep when the command also needs to carry state or support undo.