The Command of Undo Magic
Encapsulating destructive API calls into an undoable history list.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Chronomancy // Time Manipulation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// VB PATTERN //
' ICommand.cls
Public Sub Execute()
End Sub
Public Sub Undo()
End Sub
' DeleteRegistryCommand.cls
Implements ICommand
Private m_key As String
Public Sub Init(key As String)
m_key = key
End Sub
Private Sub ICommand_Execute()
On Error Resume Next
' Wipe the key
End Sub
Private Sub ICommand_Undo()
On Error Resume Next
' Attempt to restore the key (usually fails)
End Sub
The Command pattern captures requests as standalone objects, turning destructive Win32 API calls into encapsulated rituals that can be sequenced, logged, or (theoretically) undone.
Runic Tags:
#command
#undo
#registry