This is my situation I have a website, mobile client and desktop client.

They can all pretty much do the same operations (website might be able to do more now but in the future they might have the exact operation set)

The technologies varies: for website ruby, for desktop c#, for mobile objective c and java

I am wondering about two solutions

1) create an api that will be used for everyone. website, desktop and mobile. Api is the only one that can connect to the database.

2) create an api for dekstop and mobile. Website will connect to the database directly

Personally I like the approach 1) because I think its more modular and I think that its more consistent. I think the downfall is that it might be a little bit harder to test on the web side and that some features might be harder to implement (like oauth). But overall I think its a better choice.

2) is easier for the web programmer obviously but i see some drawbacks like possibly duplicating code for the same thing, not being able to be certain that the same data will be given to all clients (because the code if different) and also we loose some security with direct database access here.

I am wondering what do you guys think? And also how do big companies like facebook do it? They have a similar scenario. I guess because they are so large they might choose a more perfomance based solution like 2) but how large do you have to be before you go into that direction?


1 Answer 1


I think it depends on complexity of the interface. If the set of calls that you can make against the database is going to be significant, then something like a REST service in front of the database would make sense to limit the server side implementation and support efforts. It will slow things down by being inserted into all flows but it will enable centralized security and performance management efforts. Otherwise, you could make it language specific in the interest of shortened delivery times.

So, the question would be how important performance and latency are and how important is it minimize the short term development effort?

Not the answer you're looking for? Browse other questions tagged or ask your own question.