By Peter Bell

Verb Hunting: Four Just Isn’t Enough

In general I like the REST principle of "URI as interface". It can make for a very obvious, human readable API to your applications (for pages where the inputs required are not complex enough to require an XML wrapper), but I disagree with DHH (see my last post) – I don’t think four verbs are enough.

To be more precise, I DO think four verbs are enough. By taking a CRUD/persistence mindset (persisting carts, each step in multi-wizard forms, treating workflow tasks as objects with their own CRUD, etc.), I have always been able to map the primary intent of every page request to one of the four verbs – Create, Read, Update and Delete. But more verbs make for a more powerful, intuitive interface . . .

When I’m developing domain specific languages (DSL’s) I’m usually looking to create more languages with less expressiveness in each. In the extreme, I already have a pair of languages (ColdFusion and SQL) which will allow me to build almost any web application. However, they are so flexible, they are not easy to learn and the signal to noise ratio (minimum theoretical characters required to describe intent vs. characters required by the language constructs and compiler/interpreter to implement that intent) for ColdFusion (and most other scripting languages) is horrible. My goal is to refine a bunch of much simpler DSL’s for describing everything from lists to validations.

Because of this, I’d much rather add new verbs like "approve". Sure, we all know that an approval is just a type of update, but by breaking it out, I can create a separate, simpler, richer DSL for "approves".

To take an even more obvious example, to describe a view (a read operation), the main criteria are the object to view, the instance and/or version to view (usually based on a value of a unique attribute – ID, email, product SKU, etc.) and the attribute list to return. With a named list (which is also a read), you need the object and a comma delimited list of unique attribute values in the order you want them returned. With a filter list you might need the object, the filter, the order, the first record number, the number of records and the attribute list. In practice it is much easier to specify an application by selecting from a wider range of verbs (so read might be replaced by view, named list, filter list and report) – each with simpler parameters for specifying 99% of functionality required.

Comments
Generally I would agree with you. Four verbs are enough for about 90% of most web interactions; but I have yet been unable to cleanly map a DSL for a person to person interaction. For example I could model a person hearing a noise as "updating" /person/fred/ear/ however the response to this would not come from /person/fred/ear but /person/fred/mouth ... but the semantics of the mapping don't feel comfortable.
# Posted By Gary Leeson | 8/21/06 5:00 PM
Hi Gary,

What would be a real world example of a person to person interaction that would go through an OO system? I tend to focus on use cases that I'd realistically need to code and I don't think I've ever coded a website with person to person interaction. Usually any such interactions use the website as a blackboard, so a person saves a message or a post or an article which is then sent to or viewed by the other person so the intermediation is the message/post/article.

Do you have an example of something that'd be part of a website that highlights the problem a little more clearly?

Best Wishes,
Peter
# Posted By Peter Bell | 8/21/06 5:12 PM
Hi Peter,

REST is not just for website development; you can use the HTTP protocol and REST paradigm within or as an application server; for example I have created such a thing for a client and the app server is middle war sub-system the does not serve up any HTML.

Onto your question. I am interested in man-machine interfaces in a non-web (as in non-html rather than non-internet) way. One of these interests are in "BOT's" of various kinds and AI systems and how REST can be applied to them.
# Posted By Gary Leeson | 8/22/06 4:58 AM
Hi Gary,

Very interesting indeed! Way out of the scope of what I usually work with, but as you have any thoughts I'd love to keep up with them. Do you have a blog I could subscribe to?

best Wishes,
Peter
# Posted By Peter Bell | 8/22/06 6:33 AM
Hi Peter,

I don't do that much Blogging of late because of just getting married, work etc. Howver my blog is available at http://www.garyleeson.com/?feed=rss2 and I have just written a short blog on basically REST is not just SERVLETS
# Posted By Gary Leeson | 8/22/06 5:15 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.