Additional Thoughts about the Command Pattern
jonathan-frere.com·9w
🏗️Language Design
Preview
Report Post

A couple of weeks ago, I wrote a post on my employer’s blog titled Undo, Redo, and the Command Pattern, which I ended up quite pleased with.

Here, I wanted to add a couple of additional thoughts based on some of the discussions and things I’ve read since writing that post.

Firstly, undo/redo isn’t the only use for the command pattern! This is something I wish I’d made more explicit in that post. Perhaps a more general way of seeing commands is “functions with metadata in a consistent shape”. In our case, the metadata was the undo function, i.e. the inverse function to our original function. But you could do all sorts of other things as well:

  • User-readable data, such as the name of the command and a descripti…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help