Categories Displayed in Flash

Prevayler and AS3, ByteArray

Since I have a background in Java Server side architecture, and web app scalability. One of the areas that interests me is applying the many tools that made Java serverside so easy/power (that is when correctly used) into the Flash world.
I have used RDMBS: Oracle, MYSQL, PostGress, SQLServer, XML, OODBs: Versant, Poet and ObjectStore. The latter being a large departure in working with after working with RDBMs for so many years, as there wasn't any brittle Java<->SQL mapping code, just more complicated serialziation/deserialization.

The easiest way to think about Object Oriented databases is if your familiar with Virtual Memory Management, but when applied across multiple machines. Virtual Memory Management makes it appear to the Operating System that there is far more RAM in the system than there actually is, so you can open up that 500MB photofile, and photoshop and Windows all in 512MB or RAM and tack on that brittney spears head..though it might be sluggish, unless you have enough memory. Relatedly this sluggishness is also what happens to web apps, as they are constantly going back to disk to return a few values to the pipe. What happens is and the programs unaware are constantly saved to disk (paging) when they aren't being used and reloaded into memory when they are needed. In some cases the ENTIRE ram is written to disk, this is how hibernate works in Windows when you have a laptop. Or in the case of virtual machines, the entire PC and hardware state is written to a file/disk. Generally this process is transparent to the end users and the application inside. What an OODB does is act like a multiple machine memory manager, with gargantuan virtual memory space, where the RAM is actually on multiple remote machines. If you imagine the alphabet as our database, and say that each server could only hold 3 letter of it, that our servers might have this in memory:

  1. ABC
  2. ABC
  3. ABC
  4. ABC
  5. ME
  6. THE

One of the key to performance is keeping frequently used items like ABC in memory (in this case being popular we've saturated several machines with them) and things not used (like Z) on disk. Almost all application and network accelerators use a variant of this memory first, caching routine. RAM access times for reads and changes are 1000x or more that of the fastest harddrives. RAM has gotten so cheap that this becomes the predominate web scaling strategy, and now it's quite easy to hold 16GB of ram on a single pc. Couple this with decreased processing as there is less mapping code...if any, plus 'pointer' navigation instead of expensive table joins, it's easy to see how OODB's can be order of magnitudes faster than RDBM's on disk. That said OODB's are expensive to use, and skillsets familiar with using them hard to find. With updates to the object model you have to migrate the version 1.0 stored on disk to the version 1.2. The virtual memory just like a harddrive can get fragmented.
Anyway, A year or so later I discovered Prevayler, and it made sense for many if not most applications. It's a one machine 'poor man's OODB. This is a good article on using it.
http://www.onjava.com/pub/a/onjava/2005/06/08/prevayler.html

So what's this to do with Flash? With AS3, and the ability to clone items deeply, I think there is the ability to apply the paradigm and thus benefits to Flash.
http://www.kirupa.com/forum/showthread.php?p=1897368

http://www.richapps.de/?p=34

http://www.stimuli.com.br/trane/2007/may/09/as3-sad-bits-1-deep-copying-or-cloning/

http://niko.informatif.org/blog/2007_07_20_clone_an_object_in_as3
Prevalyer, is the Command Design Pattern, with a command log allowing undo/redo, with the addition snapshots of entire application state periodically. This is similar to tweening in flash when you have keyframe (snapshots) and between frames. Except in this case we are dealing with data instead of visual asset state.

The command log could be stored locally via sharedObject, AIR's ability to write to the file system, or on the server, AMF/Remoting, or XML. In addition if the commands share a similar value to the server they could be used on multi-user applications, that have group editing, replication/failover and undo at a reasonable price. Which would be really cool!

This has a good graph on how it works architecturally.

http://www.ibm.com/developerworks/library/wa-objprev/

Add a Comment: