Nayanjyoti Deka
Nayanjyoti Deka

Reputation: 419

Webservice or Webapp?

i have already made a RESTFul web service using Spring to be consumed by various mobile clients. Now if in future I need to make a web-portal to implement the same functionalities, which will be a more appropriate option and why ? please provide proper citations if possible

Option1: I make a new webapp which will consume the previously made RESTFul webservices Option2: I make a new webapp using the previously made codebase for RESTFul (maybe some modification required at controller layer) and integrating those JAVA code with the new webapp.

Which is more better or recommended approach and why? please provide citations too if possible.

Thanks.

Upvotes: 0

Views: 115

Answers (3)

Sachin Bhosale
Sachin Bhosale

Reputation: 26

Here are my views:

Option 1: This is good option, it will have service based dependency which will avoid changing the webapp code if any implementation changes in services. However with this it will add extra translation in new webapp.

Option 2: This will have tight coupling between service and client(new webapp). Client and server cannot evolve independently without making changes in new app. There would be constant code changes in both the project.

I would suggest you to go with Option 1. Also I have suggestion on RESTful services design. It can be designed with interfaces for all controllers or extract interfaces from existing controllers and those can be exposed as EJB for internal clients like new webapp. This way same services can be exposed using RESTful and EJB with same implementation.

Upvotes: 0

nickdos
nickdos

Reputation: 8414

Only you can really answer this question as you have far more information about the project than we do (or that you have provided). Both options are valid and the choice of which depends on the specifics of the project. More importantly the decision should be the one that benefits the user the most.

Having said that, I have been in this situation on a number of times and I've gone with both options. Both work but I'd choose option 1 more often than option 2 based on my experiences. I'd use Grails or a modern javascript framework (like Angular JS) to produce a client only app that consumes your web services. This has the benefit of being small and modular, allowing you to "eat your own dog food", and provides example code for others to use to write apps to consume your web services.

Upvotes: 0

Andres
Andres

Reputation: 10727

Option 1 will avoid code repetition, but will force you to make remote invocations with the corresponding performance penalization.

Option 2 will duplicate code on two projects, which is not a good idea.

I suggest you an Option 3, consisting on factorizing your first project, and putting the common code on a jar to be referenced from both the REST API project and the Web app project.

Upvotes: 1

Related Questions