I have a project where I should develop a mobile application(android) and a website. As both of them have the same database/content and functionality I want to write common sever side for mobile and web application.
Now I have two options:
To develop a RESTful Web service on the server side to which my android app and website(HTML/Javascript) will communicate. I think it's not a comfortable way for website development, because you have fill all HTML components value using javascript on page load.
Develop a web application with MVC framework (for example CodeIgniter) where each page will have two views:
a) common HTML/CSS/Javascript page for Web site
b) JSON data for mobile application. In this case mobile app will make a HTTP GET call to URL: www.mySite/someParameters and it'll respond JSON data as a result.
Which one is better to choose?
Or, Do you have any other suggestions?
Yes a single backend should suffice. Now design of the backend should be flexible enough to accommodate all the possibilities.
The server-side code handles tasks like validating submitted data and requests, using databases to store and retrieve data and sending the correct data to the client as required.
An application server is a software framework that delivers content and assets for a client application. Clients include web-based applications, browsers, and mobile apps. Application servers provide clients with access to business logic.
I prefer build a web application in this way:
Create a REST interface, usually with two output, JSON and XML, for example http://localhost:8080/hello
and http://localhost:8080/greeting.xml
Use some client side framework I prefer boostrap to have a responsive layout.
Use an MVC client side, like knockoutjs.com.
AJAX calls, where I call the url /hello I map the result to knockoutjs binding, in this way I have a bidirectional binding.
Build a native application for Android or iPhone using the interfaces.
I hope it can be useful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With