PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: newtriks on September 19, 2007, 05:37:18

Title: Get all or just the one!
Post by: newtriks 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?



Title: Re: Get all or just the one!
Post by: puremvc 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.


Title: Re: Get all or just the one!
Post by: newtriks on September 19, 2007, 09:06:13
Cool Cliff thanks, I will check out my remote server and see if it supports :)