Sunday, September 19, 2010

PatternCraft – Memento Pattern

PatternCraft is a series of video tutorials that use StarCraft references to teach Design Patterns.

This video is the fourth in the series and covers the Memento Pattern.

Other PatternCraft tutorials:
Mediator Pattern
Visitor Pattern
Command Pattern
State Pattern
Strategy Pattern

Source is here:


  1. johnlindquist9:51 AM

    Quick notes - You can easily combine the memento pattern with command objects, state objects, etc from the previous tutorials for much more powerful save/restore functionality. Also, in Flash, mementos are perfect for saving state locally in SharedObjects or syncing state across networks, etc.

  2. kind of noob question here - but for something like starcraft match replays - are you literally going into each object on screen and creating complex mementos like you are talking about below with command and state objects for every single character, building, event happening on screen? just thinking about that hurts my cpu - which is obviously a neuronet processor.

    i feel like creating all those instances for all the possible things going on would just destroy flash if i were to have any type of complex game - is this something where id be better off using bits for simple 0 and 1 on and off states for certain things? or is it just best used when really really REALLY planned out well? - not even sure if i worded that correctly

    tldr; complex saving in flash would murder cpu yes?

  3. johnlindquist3:15 PM

    I think you're over-thinking it. The mementos wouldn't have to be that complex (x, y, currentBehavior, state, is that it?) for maybe 200 units? And I'm sure there's a billion different caching/pooling/whatever tricks they do in Starcraft for optimizations.

  4. yea, that tends to be the case (my over thinking) but thanks for the quick response! love these tutorials

  5. wow, John!! Great classes of design patterns, especially these one.

  6. Mike W9:39 PM

    fantastic john... really helpful

  7. [...] comments PatternCraft – Memento Pattern | on PatternCraft – State PatternPatternCraft – Visitor Pattern | on [...]

  8. [...] comments PatternCraft – Command Pattern | on PatternCraft – Memento PatternPatternCraft – Memento Pattern | on PatternCraft – State [...]

  9. [...] on Video Tutorial Requests for 2011?PatternCraft – Strategy Pattern | on PatternCraft – Memento PatternPatternCraft – Command Pattern | on PatternCraft – Memento PatternPatternCraft [...]