Hacker News new | past | comments | ask | show | jobs | submit login

Of 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-... . 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?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: