A RESTful chess service: Part 1Author: Dave Cassel | Category: Software Development
I recently got a copy of RESTful Web Services, a book in the O’Reilly series that I read some time ago. I first read it when I was introduced to REST as an architectural style. It helped me get my head around a number of the concepts.
I decided that I want to refresh my memory about some aspects of designing RESTfully and to explore how to build a RESTful service using MarkLogic Server, so this post is actually the introduction to a miniseries. The book has a suggested method for going through the design steps, so I’ll walk through those steps and the implementation over a few posts. I invite you to read along and see how the process unfolds.
First things first: I need to decide what need I’m trying to satisfy. Being a chess player, I decided to implement a service that would be used by a chess organization such as the US Chess Federation, FIDE or the Free Internet Chess Server. These groups hold lots of tournaments, some of which are major international events while others are small events held by community chess clubs. In all cases, the tournament director needs to report the results to the organization, which will record the results and update players’ ratings.
Besides reporting, my service will support searching. The service should provide representations of players, events, and individual games. We’ll return player and event information as XML, but we’ll give users the choice between XML and PGN, the standard for chess notation, for individual games. We’ll need some search capability, in addition to browsing.
RESTful Web Services gives a 9-step Generic ROA (Resource Oriented Architecture) Procedure:
- Figure out the data set
- Split the data set into resources
- Name the resources with URIs
- Expose a subset of the uniform interface
- Design the representation(s) accepted from the client
- Design the representation(s) served to the client
- Integrate this resource into existing resources, using hypermedia links and forms
- Consider the typical course of events
- Consider error conditions
For each resource:
In this post, I’ve introduced the series and laid out roughly what I want to do. Next time I’ll tackle the first two steps in the process. See you then!