views:

399

answers:

2

Hi, I'm working on an iPhone application that should work in offline and online modes.
In it's online mode it's supposed to feed all the information the user enters to a webservice backed by GWT/GAE. In it's offline mode it's supposed to store the information locally, and when connection is available sync it up to the web service.

Currently my plan is as follows:

  1. Provide a connection between an app and a webservice using Protobuffers for efficient over-the-wire communication
  2. Work with local DB using Core Data
  3. Poll the network status, and when available sync the database and keep some sort of local-db-to-remote-db key synchronization.

The question is - am I in the right direction? Are the standard patterns for implementing this? Maybe someone can point me to an open-source application that works in a similar fashion?

I am really new to iPhone coding, and would be very glad to hear any suggestions.

Thanks

+1  A: 

I think you've blurring the questions together.

  • If you've got a question about making a GWT web interface, that's one question.
  • Questions about how to sync an iPhone to a web service are a different question. For that, you don't want to use GWT's RPCs for syncing, as you'd have to fake out the 'browser-side' of the serialization system in your iPhone code, which GWT normally provides for you.
Steve Armstrong
I agree that my question might be a bit blurry.About your first point - that's not what I was asking, the second point is closer.I realize I cannot use GWT's RPC, and will have to provide a custom web service, that's what I wrote in the question, I plan to provide a ProtoBufs interface.What I was asking is - is there a common pattern for this workflow? Libraries that help sync Core Data with remote data?Tutorials?
Reflog
A: 

about system design direction: First if there is no REAL need do not create 2 different apps one GWT and other iPhone create one but well written GWT app. It will work off line no problem and will manage your data using HTML feature -- offline application cache If it a must to create 2 separate apps than at least save yourself effort and do not write server twice as if you go with standard GWT aproach you will almost sertanly fail to talk to server from stand alone app (it is zipped JSON over HTTP with some tricky headers...) or will write things twise so look in to the RestLet library it well supported by the GAE.

About the way to keep sync with offline / online switching: There are several aproaches to consider and all of them are not perfect. So when you conseder yours think of what youser expects... Do not be Microsoft Word do not try to outsmart the user. If there at least one scenario in the use cases that demand user intervention to merge changes (And there will be - take it to the bank) - than you will have implement UI for this - than there is a good reason to use it often - user will get used to it. it better than it will see it in a while since he started to use the app because a need fro it is rare because you implemented a super duper merging logic that asks user only in very special cases... Don't do it. balance the effort. Because the mess that a bug in such code will introduce to user is much more painful than the benefit all together.

so the HOW: The one way is the Do-UnDo way. While off line - keep the log of actions user did on data in timed order user did them as soon as you connected - send to server and execute them. Same from server to client. Will work fine in most cases as long as you are not writing a Photoshop kind of software with huge amounts of data per operation. Also referred as Action Pattern by the GangOfFour.

Another way is a source control way. - Versions and may be even locks. very application dependent. DBMS internally some times use it for transactions implementations.

And there is always an option to be Read Only when Ofline :-)

Boris Daich