开发者

Best Practice for creating Web Services

开发者 https://www.devze.com 2022-12-25 02:30 出处:网络
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 abi开发者_开发知识库lities). In doing so I

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 abi开发者_开发知识库lities). 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.


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


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消