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: Data Layer Abstraction  (Read 10604 times)
ricardokirkner
Jr. Member
**
Posts: 18


View Profile Email
« on: May 21, 2008, 12:22:24 »

Hi. I am completely new to PureMVC, and somewhat new to Flex, but I have to develop a new application using Flex, and I though of giving PureMVC a chance.

One of the requirements of the App is that I should be able to change the underlying plattform as seamlessly as possible. By that I mean, that if I decide to start developing the app using XulRunner as a plattform, and later on I decide to better use Air, I should be able to do that as easily as possible. On the other hand I will be initially using a sqlite database for my data, but I would like to be able to later use a webservice api for invoking data storage on a remote server.

So, regarding this last requirement, I though of the following. All my proxies should just use a service for setting/getting the data, and the service should just implement an interface, so I could eventually change the underlying implementation in order to access a database through filesystem, or access a remote api through webservices, without affecting the rest of the application. In the event of changing where the data is stored, I should only have to replace the service's implementation, but not alter the proxies.

I just wanted to have your oppinion on this, what weak points you see, and/or how you would modify it for better abstraction/performance/ease of use.

thank you in advance,

ricardo
Logged
Elephant
Newbie
*
Posts: 9


View Profile Email
« Reply #1 on: May 21, 2008, 01:16:12 »

Hi,

AFAIK changing the underlying platform is pretty easy - just create a secondary project that defines the main application file with your platform-specific items and have it reference your original project.

Other than that, I think you have the right idea re: abstraction of the data layer.

Good luck!
Logged
ricardokirkner
Jr. Member
**
Posts: 18


View Profile Email
« Reply #2 on: May 21, 2008, 02:04:07 »

thanks for the answer... from what I understand you are suggesting, it might be something like... (please correct me if I am wrong)

- create a .swc with everything that is platform independent
- create a project using that .swc (so as to be able to do 'import myproject.blahblah') with only the platform specific code in order to generate the final .swf

is this right? (I kinda like the separation)

thank you
Logged
ricardokirkner
Jr. Member
**
Posts: 18


View Profile Email
« Reply #3 on: May 22, 2008, 04:14:49 »

hi. Another question.

In order to abstract the proxy implementation I did the following:

1. The proxy uses a delegate to get / set the data on the backend
2. The delegate can have many implementations, depending on the backend

Since the delegate can be a remote service call, I think I need to manage calls to delegates in an asynchronous way. For that I though of using AsyncToken (as I saw was being made when directly calling HTTPService, for example).

What I would like to do is the following:

1. The proxy calls the delegate and receives an AsyncToken
2. The proxy adds a callback for this token in order to get notified when the delegate has finished and do some stuff

and

3. The delegate might call a remote service, for which it gets a token, which it registers for result handling
4. The delegate needs to somehow modify the AsyncToken it returned with the newly received results (after some possible processing in the result handler) so that when the result handler in the Proxy is called it gets the modified result value.

or

3. The delegate performs some synchronous operation to get the data and then needs to somehow modify the AsyncToken it returned with the newly received results so that when the result handler in the Proxy is called it gets the modified result value.


Now, my question is:

is this the way to do this type of things? if so, can anyone give me some pointers here, because I am unable to modify the tokens content once created.

thank you
Logged
Pages: [1]
Print