TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

RESTful thinking considered harmful

97 点作者 Titanous大约 13 年前

11 条评论

cletus大约 13 年前
Look, I'm not a REST cheerleader by any stretch of the imagination but in REST terms the OP just doesn't know his ass from his elbow here. Consider:<p>&#62; POST /orders/42/pay<p>&#62; POST /orders/42/ship<p>You don't put verbs in your URLs. This is really REST 101. I highly recommend <i>Nobody understands REST or HTTP</i> [1]. The above is exactly <i>why</i> you don't put verbs in URLs. Consider instead:<p><pre><code> POST /payment { orderId=42, etc } POST /shipment { orderId=42, etc } </code></pre> is a much sounder RESTful API design.<p>And in case anyone feels the need to suggest SOAP, I highly recommend the satiricial (but disturbingly accurate) <i>The S stands for Simple</i> [2].<p>[1]: <a href="http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http" rel="nofollow">http://blog.steveklabnik.com/posts/2011-07-03-nobody-underst...</a><p>[2]: <a href="http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/" rel="nofollow">http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-...</a>
评论 #3779642 未加载
评论 #3778363 未加载
debacle大约 13 年前
My thoughts:<p>1. Most people who think that REST is The Best Thing Evar don't really understand what REST is.<p>2. Most people who think that REST is terrible don't really understand what REST is.<p>REST is a tool. It's useful for a lot of things. It can alleviate initial scalability issues. It can make an API easier to use or require fewer calls. It can make it easier or more intuitive for someone to learn an API, and it's very often easier to make changes to a REST API because of the way it is written.<p>But it's just a tool, and if you can't grok that, you're probably a tool as well.
评论 #3776498 未加载
评论 #3776362 未加载
评论 #3776277 未加载
webjunkie大约 13 年前
"The RESTful thinker may design both the payment of an order and the shipping of an order both as updates"<p>Maybe this thinker got it wrong. How about POST /orders/42/payment to create a payment object?
评论 #3775928 未加载
评论 #3775919 未加载
评论 #3775941 未加载
crewtide大约 13 年前
REST is a great starting point for an API, but generic REST interfaces (in Rails, Django, or any other framework) are relied on too heavily. I'm especially interested in mobile APIs, which have very specific considerations that REST doesn't answer well.<p>Building a generic data back-end for mobile is very hot right now, with lots of funded startups in the space. Some of them are just offering a REST API, which frankly any Rails or Django developer could produce in about 10 minutes. Mobile APIs need to be different, mostly due to slow or non-existent connections, and require additional thinking. More details here: <a href="http://ow.ly/9YMrM" rel="nofollow">http://ow.ly/9YMrM</a><p>Anybody know of any mobile back-end providers that are thinking innovatively about this? I've consulted a few of these startups and they all seem hesitant to make any choices that go beyond REST...but as far as I'm concerned, offering a generic solution for something that mobile devs have to develop every time they create an API would be well worth it. A simple example is to accept a guid for every created object and return that guid in the response. It's something you have to do to know that the object has been sent successfully to the server, so why make the developer code it every time?
评论 #3776343 未加载
评论 #3776281 未加载
RyanMcGreal大约 13 年前
&#62; POST /orders/42/pay<p>&#62; POST /orders/42/ship<p>But "pay" and "ship" are actions, not objects, so it doesn't make a lot of sense for them to be represented as URLs.
评论 #3776187 未加载
评论 #3776302 未加载
评论 #3776189 未加载
评论 #3776375 未加载
chrisdinn大约 13 年前
Small thing, but when the author attributes REST to Robert Fleming, I believe he actually means Roy Fielding.
评论 #3775891 未加载
MatthewPhillips大约 13 年前
Can we please kill the "considered harmful" meme?
评论 #3777802 未加载
评论 #3777671 未加载
评论 #3778003 未加载
评论 #3777541 未加载
strictfp大约 13 年前
The writer seems not to consider several other models such as<p>PUT /orders/42/payed or POST /orders/42/paymentprocessor<p>, which in my eyes would be both restful and true to the business model.
hkarthik大约 13 年前
<i>Ship with a state machine implementation by default, and a generator for a state machine-backed process model. Be opinionated!</i><p>I think this is the most compelling take away. I learned how to use the state_machine gem in my current job, and it's an invaluable tool for going beyond CRUD and building real process models.
评论 #3776660 未加载
iamleppert大约 13 年前
Is it just me or are these "considered harmful" articles becoming way too cliche? When I see one, I immediately become suspicious of it's content and distrust it as I've come to associate it with some sort of inflammatory headline or flippant way to dismiss legitimate conversation.
sgonyea大约 13 年前
tl;dr