Notes: Adobe AIR Local Data Storage Options

The following are my notes during the Adobe AIR Local Data Storage Options webinar that was presented during Adobe Developer Week. It was presented by Greg Hamer and the slides and demo code are already online.

Before getting started, note how Microsoft and Adobe are taking two different approaches: Microsoft is trying to bring the .Net desktop development community to the web. Adobe is conversely trying to bring web developers to the desktop! (Kevin Lynch)

There are four main options for AIR local storage: Local Shared Objects, File System, Encrypted Local Store, and the embedded SQLite database. Shared Objects are available in the Flash Player as well; all of these options are obviously available in AIR. Note that the data size limitation for Shared Objects does not exist in the AIR runtime!

Performance considerations. Shared Objects read and write very quickly. File system access and encrypted local stores are typically be slow in writing. Embedded SQLite databases are typically the best combination of speed and random access of items. Greg highlighted the AIR_LocalStorage_Demo app created by Jason Williams that demonstrates the speeds of the four storage methods.

Local Shared Objects. You can serialize memory resident data structures. Great! However, it runs in synchronous mode.

Encrypted Local Store. Used to store sensitive data. The price is the slow write speeds.  Also runs in synchronous mode. All data is serialized using ByteArray.

File System. Obviously important for management of documents. Can run in sync and async mode. The File and FileStream objects work together to point to a file and read/write data. The File object helps remove you from the pain of dealing with Mac vs. Windows environments with properties like File.userDirectory, File.documents.Directory, File.desktopDirectory, etc. It also has methods for opening Open and Save dialog boxes native to the environment as well as copying/moving/deletion methods.

Embedded SQLite Database.  Nice thing about them is that they are self-contained in a single file and require no external software installation to begin using them (support is built into the AIR runtime). Even supports transactions. And the database supports large amounts of data: SQLite has a theoretical limit of over 2TB. Supports ANSI-SQL 92.

However, it’s not a full-blown enterprise database server, obviously. So you lose things like stored procedures, enforcing data type constraints, foreign key constraints, and primary keys must be integers. It also isn’t a multiuser environment.

Session evaluation. I am unhappy to say that I was disappointed with the session. It was high-level, the coverage of code samples (when they weren’t passed over completely) consisted of merely reading the code back to us. I recommend viewing the recording if you have zero knowledge of data storage in Flex and AIR, as it would serve as a decent first-baby-step introduction for you.

CF8, AJAX, Flex, AIR: There’s Room For Everyone

The ColdFusion community has been paying attention to IT journalism lately, for better or worse, and for good reason. Our environment is especially in a state of flux; many of us may had been concerned about the future of ColdFusion given Adobe’s acquisition of Macromedia, but those fears were allayed, especially now with Adobe making it so clear that they have invested respectable time and resources into improving ColdFusion with CF8. But the results of the acquisition are only just beginning to emerge. And as Adobe’s strategy becomes clearer, it is very evident that they are putting arguably more resources into other technology like Flash and Flex.

What ultimately prompted my thoughts was the article Web 2.0 Needs Adobe by Tom Yager. His discussion is very flattering for Adobe, although ColdFusion isn’t mentioned anywhere. Neither is it mentioned in Cringley’s equally flattering article An AIR of Invisibility. There’s a reason for this. They’re focusing on the user interface of apps, which is really what defines the perception of how responsive and powerful an app can be. Fretting about ColdFusion getting the back seat is like fretting that your favorite athlete wasn’t nominated for an Oscar; it wasn’t really up for consideration.

So, user interface. Now that’s something to fret about. Many of us don’t like to think about the UI, and that has to change! User interface has always been important when users form their impression of an app, and that high priority is applying more heavily to web apps as they begin to vie for user acceptance with their heavier desktop brethren.

Most ColdFusion developers are using HTML for their user interface. An industry migration will hopefully migrate that median toward AJAX-enhanced HTML or Flex interfaces for web apps, and of course AIR for desktop apps. ColdFusion won’t be going anywhere, as our internet connectivity is always going to need a server-side component.

So how are we to react to these articles’ evaluations of AJAX and Flex? In a way, they are depicting JavaScript (and thus AJAX) as a dinosaur with wings. It is powerful, it got a shot in the arm with the popularity of AJAX, and it can do amazing things. But it’s still a “dinosaur”. It is old technology trying to keep up. Enter Flash and Flex. The new kids on the block. They’re more modern–but they’ve had time to mature–and they just out-perform AJAX in what they can accomplish. Now tack on thoughts about how much AJAX functionality Adobe has put into CF8. What’s the point if AJAX is inferior to Flex? What does it all mean?

It’s a big internet out there. Various scenarios call for various solutions! Whereas it is a good idea for us as ColdFusion application developers to learn Flex and start using it when UI needs call for it, the ultimate point is that we start improving our UIs from plain HTML. Start putting more effort into the user interface. We’ve had it easy in the past when simpler, less sophisticated interfaces were accepted on the web, and that time is coming to an end as the web pushes forward as a viable application platform.

Is it urgent that we start learning Flex? I feel that AJAX and Flex will be sharing the web application space for a long time. Yes, Flex and Flash might be Adobe’s ticket for bringing web apps to the next level, but their commitment to AJAX is very clear. That is evident in the AJAX support in CF8 and AIR. Learn Flex if you can. If it’s just too much for you to handle right now, AJAX is a fine step–more palatable and familiar for HTML developers–that will let you focus on the more important point: Improving your app’s user interface.

Scriptaculous Cheat Sheet

If you’re not using Scriptaculous yet, start using it!

And once you do, you can reference this awesome Scriptaculous Cheat Sheet designed by Amy Hoy of Slash7.  She did a great job at covering the basics, keeping it simple.

Generate Awesome AJAX Loading Animated GIFs

When you’re putting some AJAX functionality in your site, you naturally need to provide some UI feedback elements to let the user know when you’re pulling data down from the server. If you’re all about the code and find it painful to do graphic design (like me), you’re not about to whip out any kick-butt Web 2.0-ish graphics to provide that feedback.

Now you don’t have to. The awesome Ajaxload service will generate a variety of typical AJAX loading animated GIFs that you can customize to your site’s color scheme. Awesome!

  Theme Brought to you by Directory Journal and Elegant Directory.