|
Hi everybody, I just looked at Zend\Rest\Client\RestClient, and am wondering how you think about its usefulness. Looking at the component it is mostly a wrapper around HttpClient. In general, REST means using HATEAOS (not hardcoding links, simply following the ones supplied by the API). Also, REST best-practices (please see R. Fieldings thesis) tells one to use resources only, not actions (unlike xml-rpc or soap). In its current state, Zend\Rest\Client ignores both of these. It simply visits to a url that is supplied (which is pretty much what HttpClient does for you as well) and its magic __call() method endorses the use of verbs, rather than nouns in an api design. Looking at this very same method it is impossible to call a url like /user/Freeaqingme/nonsenseEmails/archives/123, which one could very well consider a 'RESTful' url (it's nested and descriptive).
Looking at Zend\Rest\Client\Result one can see it prescribes the use of XML. Obviously, nobody uses json in their api's, right? ;) Furthermore, it also assumes the presence of certain elements like status, message, and response. It does this however using non-absolute xpath queries. This is asking for errors.
I absolutely do see a use case for restful clients, but then it should be part of a model layer. The past 14 months my job has been designing REST API's and thinking how to best consume them. As such I have done several implementations for my model layer and that really does speed up RESTful API consumption. This component though, merely endorses bad RESTful API-design, and will - I think - in no way help anyone in the real world consuming RESTful API's.
Herefore, I would suggest immediate removal of this component from the current master branch; and perhaps 'get it right' after we have put more thought into a model layer. I am however curious to find out how you guys think about this all.
Kind regards, Dolf Schimmel, ZCE -- Freeaqingme
|
|
Administrator
|
Just a quick note...
In preparing to move the service components out, Ralph noted that only a handful were using Zend\Rest\Client, and he refactored all but Twitter to remove its usage. Twitter uses it much more heavily at this time, and will need a bit of refactoring to only use the Zend\Http\Client. As such, he's: * Moving Zend\Rest into a separate repo * Having Twitter define that repo as a dependency * Offloading when we refactor to whenever somebody wants to submit a pull request. So, basically, no disagreement from my team on this -- just a question of getting some of the work done. -- Dolf Schimmel <[hidden email]> wrote (on Thursday, 12 July 2012, 08:12 PM +0200): > I just looked at Zend\Rest\Client\RestClient, and am wondering how you think > about its usefulness. Looking at the component it is mostly a wrapper around > HttpClient. In general, REST means using HATEAOS (not hardcoding links, simply > following the ones supplied by the API). Also, REST best-practices (please see > R. Fieldings thesis) tells one to use resources only, not actions (unlike > xml-rpc or soap). In its current state, Zend\Rest\Client ignores both of these. > It simply visits to a url that is supplied (which is pretty much what > HttpClient does for you as well) and its magic __call() method endorses the use > of verbs, rather than nouns in an api design. Looking at this very same method > it is impossible to call a url like /user/Freeaqingme/nonsenseEmails/archives/ > 123, which one could very well consider a 'RESTful' url (it's nested and > descriptive). > > Looking at Zend\Rest\Client\Result one can see it prescribes the use of XML. > Obviously, nobody uses json in their api's, right? ;) Furthermore, it also > assumes the presence of certain elements like status, message, and response. It > does this however using non-absolute xpath queries. This is asking for errors. > > I absolutely do see a use case for restful clients, but then it should be part > of a model layer. The past 14 months my job has been designing REST API's and > thinking how to best consume them. As such I have done several implementations > for my model layer and that really does speed up RESTful API consumption. This > component though, merely endorses bad RESTful API-design, and will - I think - > in no way help anyone in the real world consuming RESTful API's. > > Herefore, I would suggest immediate removal of this component from the current > master branch; and perhaps 'get it right' after we have put more thought into a > model layer. I am however curious to find out how you guys think about this > all. > > Kind regards, > > Dolf Schimmel, ZCE > -- Freeaqingme -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc |
| Powered by Nabble | Edit this page |
