1

So, I'm developing an android app to teach myself some of these concepts. I'm currently working on a backend using Spring Boot, which I am implementing as a RESTful API.

I've been doing a lot of reading on the matter and everyone seems to have a different approach, and I'm too inexperienced and naive at this point to know better.

What I'd like to do is have a way to also implement a website component of the app (since the app is android only, and I need to be able to allow iPhone and desktop users to get at it, and I may end up using something like PhoneGap for this purpose).

My current understanding presents me a few paths, and I'm not sure what to do or how to do it.

One way, I could create a bunch of JSP templates and modify my REST controllers to return the page based on information included in the header determining whether the JSON is needed or the full page is desired for web. An obvious downside would be requiring to controller methods for each URL (one returning JSON and one returning HTML/JSP following the MVC pattern).

Another approach I could conceive of would be to create an entirely separate application for web that just treats the REST API as a data source for filling out it's pages. This could even be done with something like PHP or Javascript. The downside, of course is the extra work of developing (and maintaining) an entirely separate application, and the tons of boilerplate that would be needed to interface with it for every little bit of data needed.

Can someone clear this up a little? My head is swimming. I know I'm not the only one with this problem, but finding quality information on the topic is surprisingly difficult.

8
  • One doesn't "return JSP". The JSP just generates HTML/plaintext Commented May 24, 2017 at 17:51
  • I'm aware, but it seemed easier to say that. Commented May 24, 2017 at 17:51
  • Similar to how one doesn't return PHP. Commented May 24, 2017 at 17:51
  • So other than this question seeming a bit broad/opinion based (i.e. "which framework should you use"), where exactly are you stuck in implementing this? Commented May 24, 2017 at 17:53
  • In the architecture of the thing. I'm not looking for a technology to use, but rather, approaches and patterns that would be suitable and recommended. Commented May 24, 2017 at 17:57

2 Answers 2

2

You can keep your back end services Rest Bases. So that you can have good code maintainability and scalability. You can build Android apps to consume your rest api and render the views, and likewise you can build SinglePage apps using frameworks like Angular, ReactJS to consume the server side rest apis and render the views.

They may have to be handled as two separate projects, which I see as an advantage to handle. Any change in the Rest APIs structure may have to be changed in both client projects, and again this can be managed using good documentation tools (like Swagger.io) and proper integration test cases automated.

I have built Android native apps, web frontend(Angular), services( spring boot and scala) with this approach in past and doing good in this architecture.

Sign up to request clarification or add additional context in comments.

2 Comments

One notable downside would be additional network communication required between the two. Thoughts?
Yeah when it comes to App to services the network overhead may be considerable, which is any how not avoidable since the apps run on user phones. But when it comes to Web Front end and services, you can make sure they are available in same server machine or in same network so network lag may be considerably small.
1

You can do pretty well with fully rest based web app too! You can actually re-use a lot of code with your hybrid android app you're creating.
If you want to go with mvc, you can have a single server with common service and dao layers for all apps, and different contollers for web and rest.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.