From Ajax Patterns
|Revision as of 07:54, 14 March 2007
126.96.36.199 (Talk | contribs)
← Previous diff
Stefan Hintz (Talk | contribs)
Tags: Object Persistence
In A Blink
Object persistence has become an important part of many development projects because of the improved structure of coding that it provides. With object persistence, objects can be manipulated with normal programming techiques, and their state can be stored in persistent storage (on the server or client). In future sessions, the persisted objects can be restored to their previous state.
Standard object manipulation is a very natural programming technique. Persisting objects in other languages has already proven very powerful in improving code structure, for example in Java (O/R Mapping implemented through Hibernate, JPOX, etc), and simplifying the job of storing state information.
When to persist the object data?
Objects can be explicitly loaded and saved. Or you can use a class of persistable objects that manage get and set calls, and the data can be persisted when these calls are made.
Where to persist the data
Object data can be stored on the server through remote calls, or it can stored locally using a local storage technique such as Dojo.Storage.
Ajaxdo is a framework to save and load objects to a server connected to an SQL database.
Authenteo uses a language extension of # symbol (it does precompilation) to denote persisted fields (to allow for transient fields as well) on persistent objects. For example if you have an object that represents a list of webpage objects in a persistent object "listOfPages" we could this:
var webpage = listOfPages#; // get the third page in the list var pageName = webpage.#name; // get the name of the page var pageContents = webpage.#content; // the contents of the page
Now we could change the name of the webpage:
webpage.#name = "New webpage name"; // This change is immediately sent to the server, and is persisted
Submission Throttling is often to keeping data transfer fairly transparent to the user. All you need is a function that periodically uploads all state. Then, another function can be used to pull it down when the user logs in again - a form of Multi-Stage Download.