3 ms·
Does anyone have any recommendations for good REST books? For example, the book cited in the article - is it good? I understand the basics of REST, but I want
by edanm 14y ago
Does anyone have any recommendations for good REST books? For example, the book cited in the article - is it good?
I understand the basics of REST, but I want to get a deeper understanding. Also, I still regularly encounter situations where I'm not sure what the "best" thing to do is (collections of items, linked items, etc. - how to represent this with REST?).
- kristopolous 14y agoDo you have any concrete examples?
- edanm 14y agoOf problems? Sure. Let's say I have a "Student" resource and a "Course" resource. And there's a many-to-many link between Students and Courses. How do I connect them? How do I get a list of the Courses the Student is enrolled in? How do I add to this list? Let's say I want to see a "latest courses" list in my homepage, some of which I'm enrolled in - how do I know which ones? This I solved, for example, by adding a paramater "enrolledIn" to every course, which returns true or false based on the user making the request. New courses I'm enrolled in are added by updating this field (even if the rest of the Course object isn't editable, because I'm not its owner). But is this the correct solution? Is there a better way? I'm not sure. Let's say I have a Course, which has a "Textbook" resource associated with it (1 to 1). How do I represent this? When getting a Course, should I return the Textbook resource embedded in this? When updating a course, how do I change the Textbook the Course uses? By passing in a new object? Alright, so can I update the Textbook by passing in the same Textbook object to the Course resource, but modifying some of its paramaters? And lastly, my thorniest problem - modeling fax-inheritance. I wrote this problem on StackOverflow here: .http://stackoverflow.com/questions/13190797/modeling-object-inheritance-in-a-rest-api http://stackoverflow.com/questions/13190797/modeling-object-... . Following is a brief explanation (but you should really look at the SO link): Let's say my system has a "User" resource that has several paramaters like "Name". Let's say my Student, in the database, has a foreign key to the User (it's a 1-1 relationship, but not every User is a Student, of course). Note that Students are the ones that are enrolled in courses, not Users. How do I model this in my classes? Do I model this as a Student that "Has-a" User object? When I log in, do I keep a copy of my User object? But what if I'm a student and want to do different things if I'm a student? Also, let's say I have comments somewhere in my application. Comments are owned by users. So let's say I get a list of comments, and their authors - do I return a User object? But what if I want to highlight all the comments posted by Students? How do I differentiate?
- czzarr 14y agoSteve Klabnik's is pretty good: http://designinghypermediaapis.com/ http://designinghypermediaapis.com/ And there is this one http://www.amazon.com/Building-Hypermedia-APIs-HTML5-Node/dp/1449306578 http://www.amazon.com/Building-Hypermedia-APIs-HTML5-Node/dp... also which is longer but more detailed. You don't need to know anything about node to understand.
- edanm 14y agoI took a look at Steve Klabnik's a few days ago. Honestly, I couldn't get into it - I'm not sure why, but I felt it was disorganized. I felt there was no way to really jump in from the beginning, get a good ground-level understanding, and then progress to more advanced topics. It felt more like a collection of articles targeting people with various backgrounds and levels. Maybe I'll be back to it after I've read another resource - it's quite possible Steve's is simply for someone who understands more about these concepts than I do.
- czzarr 14y agotry the other book I shared then, it will probably suit you better.
- smharris65 14y agoTry the REST cookbook: http://www.amazon.com/RESTful-Web-Services-Cookbook-Scalability/dp/0596801688 http://www.amazon.com/RESTful-Web-Services-Cookbook-Scalabil...
- edanm 14y agoI've been working through it. It's pretty interesting, although it's definitely arranged around the "Cookbook" concept - specific questions and answers. I feel it's missing a "let's show an example REST api - here's the resources, here's how you do things, here's why we built it this way and not another". Of course I'm still on the 3rd chapter, so it might be heading in that direction. An interesting book in any case.