views:

570

answers:

2

Can anyone tell me what design patterns (if any) were used when building Gmail? I understand the concept behind it - queue up some requests, increment the bar when each completes, init the display when all are down - but I'm specifically interested whether there's a specific design pattern I can use to mimic the features.

+1  A: 

I had a similar issue and solved it like so: Data preloading works by sending async requests to the server. When the progress bar is visible, I increment a counter for every request. The size of the progress bar == counter. Since the requests are sent quickly, the user never notices that the max value of the progress bar changes.

As a request answer comes in, I advance the progress bar once each time. That's all to it. When the last request arrives, the preloading is finished.

This looks better when the replies are small and arrive in quick succession but it works in all cases.

Aaron Digulla
Thanks; I understand the concept behind aggregating data through multiple ajax calls. What I'm more interested is if there's a "name" for the pattern which I can look further into.
digitala
If you use AJAX you don't need to be aware with the waitings
xgoan
@Phillip: I'm not sure it has a distinct name. I'd call it "performance optimization".
Aaron Digulla
@xgoan: I say: "With AJAX, you *can* be aware of the waiting." I use them to tell the user that my app is busy when I know that it will be busy for a noticeable amount of time.
Aaron Digulla
A: 

One trick that I've used successfully is to preload Ajax data as JSON: As part of the initial page load, I send down useful seed data as inline JavaScript.

George V. Reilly