Moving from a Web Service to Couchbase

54 views
Skip to first unread message

Federico Hernandez

unread,
Dec 30, 2014, 1:11:51 PM12/30/14
to mobile-c...@googlegroups.com
Hi everybody,

We have a product which involves a mobile application, a web application and a web service. The mobile and web apps retrieved the data from the web service. We needed to implement the offline feature in the mobile app, so we decided to move to Couchbase. So now, the mobile app makes every request to the Couchbase Lite and synchronizes the data through the Sync Manager to the remote database. To do so, we had to move some business logic to the mobile app. However, the web app still uses the web service.

Now, our doubt is that if we wanted to add a new business rule (a new functionality) to the web service, we should replicate the functionality in the mobile app, or if we had to add a business rule in the mobile app, we should replicate the functionality in the web service. Is there a better way to do that to avoid replicating code?

Thanks in advance,

Jens Alfke

unread,
Jan 1, 2015, 2:36:53 PM1/1/15
to mobile-c...@googlegroups.com

> On Dec 30, 2014, at 10:11 AM, Federico Hernandez <fede.he...@gmail.com> wrote:
>
> Now, our doubt is that if we wanted to add a new business rule (a new functionality) to the web service, we should replicate the functionality in the mobile app, or if we had to add a business rule in the mobile app, we should replicate the functionality in the web service. Is there a better way to do that to avoid replicating code?

It depends on the details. But often, yes, you'll need two implementations, because effectively you have client apps on two different platforms (mobile and web.) And you can't have the mobile app call through to the web implementation because that would create a direct dependency on the network, so the mobile app wouldn't be able to work offline.

If the new logic can be implemented entirely in the back end, without affecting the UI or data validation, then you might be able to implement it as a server-side task that watches changes to the Sync Gateway database. Then neither client needs to be updated. For instance this could be something that notices a specific property being added to a document, and creates some new document in response.

—Jens

Federico Hernandez

unread,
Jan 2, 2015, 2:15:05 PM1/2/15
to mobile-c...@googlegroups.com
Thank you Jens for the answer.

Reply all
Reply to author
Forward
0 new messages