Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Advice on parsing data into VO's via proxies. SQL v XML...  (Read 3780 times)
mattb
Newbie
*
Posts: 7


View Profile Email
« on: January 12, 2010, 11:18:50 »

Hi, I need some architecture advice re persisting data and parsing to VO's via some proxies..

We have an Air app that polls web services, and creates messageVO's of the items that are returned.

We are now looking to add some persistence of data, so storing read/unread states etc.

First thoughts are to create SQL db, store a table of Services, and table of Messages with states such as read/unread and message data so they can be read offline etc.

The issue is - when should this be read/written to?

The app boots, load up all the messages and parses them to VO's.  If a VO's "read" property is set to "true", we also update the DB at the same time.

However, if we search the DB for all unread messages, we then need to parse the results again. Effectively duplicating all of the VO's. The original VO's would not reflect the new states - and we have 2 VO's for the same data source.

Ideally, we need to somehow query the database for the items, but then return the already existing VO's from the proxy - the proxy could match results from the DB recordset to the VO ids, but that just feels a little clunky. Or it could replace the VO in the arrayCollection in the proxy, but this still leaves the original hanging around, and any view running off the origional VO would no longer be updated as the new VO changes.

We could get the proxies to do all the searching within their data and not use the DB at all, that wouldnt be as powerful, or as fast probably - and we may as well just save all the data as XML, parse on app boot and persist on shutdown and do away with the SQL db all together.


Does anyone have any thoughts / suggestions.

m.


Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 13, 2010, 12:42:01 »

If you like slinging lots of SQL and worrying about evil characters and all that, you can certainly go that way. Depends on the amount of data you're dealing with as to how cost-effective the approach will be. Personally, I like XML a lot because it is an AS3 data type, and we have lots of powerful searching and manipulation capability built in with E4X.

If you want to try it with XML, I suggest using or at least looking at the XMLDatabase utility. It's pretty handy. It's also used internally by another utility, the DesktopCitizen utility. You can see them both in action on the CodePeek demo.

DesktopCitizen allows your AIR app to remember its size, location and window state at startup. It does this by reading an XML file created or read by the XMLDatabase utility. You can also extend that facility to store your own application preferences or anything you'd like.

You can combine the XMLDatabase utility with the concept of a 'Smart VO'. See an example of a 'Smart VO' here: http://forums.puremvc.org/index.php?topic=1293.msg5973#msg5973

-=Cliff>
Logged
Pages: [1]
Print