[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: REST has too many verbs
> -----Original Message----- > From: Mark Baker [mailto:distobj@a...] > Sent: 12 February 2002 01:47 > To: Gavin Thomas Nicol > Cc: xml-dev@l... > Subject: Re: 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 [*]: Start: class X { String getFile(); } class Y { String getName(); } End: 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 said: >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? Cheers, L. [*] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|