Best Practice for creating Web Services
Asked Answered
P

5

6

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 the Java EE technology stack if this influences the setup at all.

Polypody answered 28/3, 2010 at 18:50 Comment(0)
C
3

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..

Cirilla answered 28/3, 2010 at 20:30 Comment(3)
you are talking about the Java layer that actually interacts with the database correct?Polypody
Correct. Interacts with the database and performs your business logic, validation logic, etc.Cirilla
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.Hiroshige
F
1

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.

Forceps answered 28/3, 2010 at 19:25 Comment(2)
thanks will read...though does this mean I completely botched the question?Polypody
ah ok :P it was definitely an insightful article.Polypody
O
1

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.

Oration answered 31/3, 2010 at 16:14 Comment(0)
S
0

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.

Schoolmistress answered 28/3, 2010 at 19:39 Comment(1)
thanks, I have considered both and REST was the ultimate decision based on the re-usability requirements.Polypody
L
0

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.

Lehrer answered 29/3, 2010 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.