Browsing articles from "March, 2008"
Mar 10, 2008

Saving Flex’s Application State to a Database

Bill Sanders has a great post on the Memento design pattern over at his blog. After reading it, I thought I’d chime in and post a technique that takes the memento one step further. This approach allows you to serialize a Memento object into a ByteArray and save it into a database. Then, retrieving the Memento object from the server, dynamically instantiated it, and restoring its previous state.

One major draw back to the Memento, as you’ll see, is that restoring an object’s state can be a very expensive operation. Especially in a Flex environment where restoring a Memento could trigger a large display list invalidation. For that reason, the Memento is not always the ideal pattern for implementing undo/redo functionality. The alternative pattern for implementing this functionality is the Command pattern. With the Command pattern, each command is only concerned about a particular action to get to the current state of the application. With this, you can have an undo() method in each of your commands that undoes whatever action was performed in your execute() method. Continue reading »

About Dan

  • I'm the Lead Software Architect at Mixbook. A rapidly growing online photobooking and scrapbooking company.
  • I built Cayri, an online monitor for flight simulator networks.
  • I enjoy learning guitar, astronomy, beer, music, programming, and driving with no apparent destination.
  • I live in San Jose, CA.

Categories

Twitter