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: Get all or just the one!  (Read 8030 times)
newtriks
Courseware Beta
Full Member
***
Posts: 23


 - newtriks
View Profile WWW Email
« on: September 19, 2007, 05:37:18 »

Hi all,

Here is a question I am sure is asked or pondered on by some people out there.  On retrieving data from a database into a Proxy i.e. users, what is better:

A) Retrieve all the users and there data and populate an ArrayCollection with the information.  This ArrayCollection can then be referenced for information by all mediators.  PROBLEM initial loading time for all the data to populate ArrayCollection.

B) Make an individual request to the database for one record.  Each time a new record is required make another call to the database.  PROBLEM repeated to and fro to database.

Which is the general opinion as being the best practice here?

Cheers,

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



View Profile WWW Email
« Reply #1 on: September 19, 2007, 09:01:32 »

With a large number of rows, either choice is a compromise.

One way to approach this is with a a paging scheme.

Depending on your server-side tech, you may already have support for paging.(Flex Data Services, now LiveCycle Data Services ES) has this support built in when communicating with Flex.

But let's say your building a Flash client to talk to a custom Perl service and you have to roll your own paging scheme.

Essentially the service needs to filter the query to a range of rows based upon a given page size an page number starting point supplied by the client.This is how most public APIs work, like google for instance.The query also needs to return the total number of results as well, so you know how far you can page.

Then, on the client, you need to use this info to allow the user to page thru as if the data were all there to begin with.

-=Cliff>
Logged
newtriks
Courseware Beta
Full Member
***
Posts: 23


 - newtriks
View Profile WWW Email
« Reply #2 on: September 19, 2007, 09:06:13 »

Cool Cliff thanks, I will check out my remote server and see if it supports :)
Logged
Pages: [1]
Print