views:

33

answers:

2

I'm thinking about building an application with a RESTful web service. My thought is to build the RESTful (json, etc) part of the application as a standalone, and then the frontend (e.g. html/css/js/etc) as a client to that service, although not through js, I'd like the web page to work without js, so probably using something like LWP to make the calls. Basically the result is 2 separate apps. Is this a bad idea? good idea? I realize this is somewhat subjective.

+2  A: 

I think it's a good idea.

It means that at the end of it:

  • You'll have a full API with at least all the functionality of your native graphical interface. So you won't end up with any functionality in your graphical interface that is not available as a service.

  • You'll avoid some duplication of effort, because all the effort you go to in order to get the graphical interface working properly will also be reflected in the web service because they use one and the same function. Fix a bug in one and it is fixed for the other.

  • This also means there is consistency.

  • Automated testing is potentially easier.

  • It's good to keep things modular especially in open source as it makes it easier for someone to then go out and write a separate graphical interface to your service, or even to modify your service while using the same graphical interface.

thomasrutter
A: 

The main problem that I would expect to see with this type of architecture is that will not be building what you think you are. Chances are the RESTful part of this app will be frontend that delivers text/html with links to allow the client to discover your application.

The part that you think is the RESTful web service, will likely not be RESTful. Are you planning to embed links in the responses from your web service? Will you be delivering a media type that has more semantic meaning than application/json or application/xml? If not your web service is not RESTful.

I'm not saying what you are doing is wrong, I'm just saying you may not be doing what you think you are doing, so be careful using the RESTful constraints to guide you, as you will likely find it very difficult to apply them.

Darrel Miller
I simply said json and xml etc as a way to make sure I was giving clarity. Part of the reason I'm thinking of doing it this way is I find it really difficult to create a complete restful application on the user side, mostly due to browser limitations than representations.
xenoterracide
@xenoterracide The web browser is by far the most RESTful client around. What browser limitations are you finding cause you problems?
Darrel Miller
forms, although I believe HTML5 adds support for PUT and DELETE in forms, I'm not sure that any browser has yet implemented this. I have also had noted problems due to lack of 'skinability' in forms which result in people using images and links (which must be in rpc fashion) or javascript to skin them because the browsers don't allow you to skin form elements.
xenoterracide