views:

230

answers:

5

To preface I am new to web development. I am looking at creating a core set of RESTful web services around a valuable document library of sorts (initial CRUD abilities). In doing so I am theoretically creating a perfectly re-usable and scalable back-end to be used by unanticipated applications in the future.

My question centers around the best practice for doing this. My initial requirement has me also creating a unique front end. Would I make the front end and back end completely separate projects to enhance the re-usability. It would increase overhead.

Looking at using GWT, Restlet, and JEE technology stack if this influences the setup at all.

A: 

Martin Fowler wrote a very nice article about the basics of REST short time ago: Richardson Maturity Model. Found it very helpful to understand the principles of REST.

Dominik
thanks will read...though does this mean I completely botched the question?
Holograham
No, did not want to imply that. Just found the article very insightful.
Dominik
ah ok :P it was definitely an insightful article.
Holograham
A: 

You may want to consider using GWT-RPC instead of REST if you know you're going to be using GWT for the frontend. More discussion here.

However, if you think you might want to eventually expose your data via a REST API, or use a different technology on the frontend, REST may be a better choice.

The gwt-rest project may also be helpful.

Jason Hall
thanks, I have considered both and REST was the ultimate decision based on the re-usability requirements.
Holograham
+2  A: 

Most important is design a clean Java API - independent of REST, RMI, or whatever protocol you want to use. From a clean Java API, you can support any access method.

Unless you have a use case for these other access methods, don't build them now. You can build it when you need it.

The easiest interface to add initially is a web based interface where your web app runs in the same JVM as your core API. I'd do this if this works for your use case. Building a separate console application that accesses your core API via a REST (or whatever) protocol is a lot more work..

Marcus
you are talking about the Java layer that actually interacts with the database correct?
Holograham
Correct. Interacts with the database and performs your business logic, validation logic, etc.
Marcus
This answer is a good one. The only thing I would add is to consider your deployment/implementation concerns - are you happy having your view tier running in the same JVM as your busines/data tier? Or, for instance, does your data tier need to sit behind a firewall? If these aren't important to you, by all means put your focus on designing a good API and leave the exotic stuff for later.
Steven Mackenzie
A: 

A colleague and I have written a GWT system using separate projects for front and back ends. It has been helpful to keep things quite clear about where the code is executing. But I'm not sure that I would bother separating things in a future system.

Also, given you're new to web development, I don't think you should be expecting to make a perfectly re-usable backend. You will learn lots of things as you go. I think that agile coders would recommend an iterative approach of (a) getting a small aspect working, and then (b) refactoring it to make it beautiful.

John
+1  A: 

If you want to use REST based backend services, you should use the RestyGWT project which allows you you to use a GWT-RPC programing style to access your JSON based restful services.

The nice thing about using REST based JSON services over traditional GWT-RPC services is that those services can then be used by other clients or even in mashups more easily.

Hiram Chirino