Monday, November 05, 2007

Flex client-server data exchange

Flex programming is much like classic client-server stuff (at least, compared to a web app). So, here's a challenge we faced when designing viibee:

The user modifies data on the client and these mutations shall, of course, propagate to the server. The question is: shall the data be modified locally (on the client) before the server received the changes or shall the client modify the data only after the server has persisted the changes? Let's call these two scenarios "optimistic" and "pessimistic", respectively.

In the pessimistic model there is less chance of an inconsistency of the data between server and client. Also, the user can always be sure that his changes have really been persisted. But you loose a lot of responsiveness of the UI (and this is why you chose to do a RIA, isn't it?).

In the optimistic model you have a much more responsive UI. But you might need to implement certain logic twice, especially some data validation will have to be done on the client and maybe on the server again. Plus, you will have to handle the case that errors occur on the server.

We thought of the pessimistic model as a "banking app" and the optimistic model as "GMail". Interestingly enough, Adobe has described the optimistic model here and describe it in terms of a banking application.

In the end, we have chosen the optimistic model and have not looked back so far.

No comments: