OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: [xml-dev] REST has too many verbs

[ Lists Home | Date Index | Thread Index ]

> -----Original Message----- 
> From: Mark Baker [mailto:distobj@acm.org]
> Sent: 12 February 2002 01:47
> To: Gavin Thomas Nicol
> Cc: xml-dev@lists.xml.org
> Subject: Re: [xml-dev] REST has too many verbs
> > > getFile(), getName(), getArticle(), getStockQuote() were what we had
> > > *before* the Web.  I can't see any reason to go back after seeing
> > > what can be achieved with GET.
> > 
> > What does that have to do with REST then?
> Each of those methods returns a representation of something; a file, a
> name, an article, a stock quote.  REST says that all of those actions
> can be generalized with a single verb, GET, and that the noun should be
> identified by a URI.

So to couch this in OO/Refactoring terms REST says that you should do 
this kind of refactoring [*]:


class X
  String getFile();

class Y
  String getName();


interface Gettable
  String get();

class X implements Gettable {...}
class Y implements Gettable {...}

IOW, RESTful-ness is about relying on a standard interface 
to resources, which contains only four methods. The URI 
determines resource identity, i.e. the object to which the method 
is sent. The resources are polymorphic, in that the same operations may 
involve different processing once invoked.

Does the analogy hold? Where does it break down? Probably in 
the next bit...

Paul Prescod included similarly illustrative example in [1] which had 
a Java method dispatching on an action name (if..else if...), and 

>Now if you were taught to program in this style, you might think it odd
>when someone told you that there was really no need to dispatch on a
>name passed as data. In fact you could move that out to the method name
>(or in the case of the Web, to the URI/method combination).

Actually I doubt whether any OO programmer would think it odd. 
It's simply ReplaceConditionalWithPolymorphism [2]. 

I'm probably stretching the analogy way to far, but is it a case 
of applying the same pattern but in a different context? 



[*] I'm not being literal here, just borrowing the pattern
[1]. http://lists.xml.org/archives/xml-dev/200202/msg00391.html
[2]. http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html

Leigh Dodds, Research Group, Ingenta | "Pluralitas non est ponenda
http://weblogs.userland.com/eclectic |    sine necessitate"
http://www.xml.com/pub/xmldeviant    |     -- William of Ockham


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS