I''ve been playing around with EdgeRails and checking out some of the new features. The one that will probably have the biggest affect on my designs is join models (or :through associations). For those not familiar with this feature, it lets you replace your habtm association with a pair of has_many associations indirected through an intermediate model class. Looks like good stuff. The thing that makes me cry is trying to name the darn join model classes. In his Pursuit Of Beauty presentation, DHH uses the example of an Authorship join model class to represent the association of an Author and a Book, and a Tagging for a Taggable and a Tag. Those examples are fairly readable, but I''m noticing that many other relationships are harder to name. I think the problem is trying to turn a verb-type relationship into a noun-type reification of that relationship. For example, what do you call the reification of the relationship of a Participant to a Meeting? A "Participation"? An "Attendance"? What about a Student to a SchoolClass? A ProjectManager to a Project? Start pluralizing and things get even uglier. Naked join tables have their drawbacks, but at least they are easy to name. I suppose I could name a class ParticipantEventJoin to get a table participant_event_joins. While that would make things very obvious it lacks a certain charm. Maybe there is a better formula for coming up with a standard name. Any ideas? --joshua susser
If you are seriously struggling to find a name, it could be a sign that your join doesn''t really need to be a model. First, your participant/meeting example. I think what you have here is a case of a mis-named model. People attend meetings, not Participants. A person only becomes a participant once they go to a meeting. You can always try approaching it this way. What does object x do to object y? A person *attends* a meeting. Person > Attendance < Meeting In order to attend a class, a student must enroll. Student > Enrollment < SchoolClass A project manager is assigned to a project. ProjectManager > Assignment < Project Maybe, an employee only becomes a project manager when they are assigned to a project: Employee > Assignment < Project In the above, as well as linking together an employee and a project, the Assignment model also holds details of the assignment type (developer, manager). Ultimately, if you are really struggling with a name, it might just be a same that you don''t need a join model, all you need is a simple habtm relationship and a plain jane join table. Cheers Luke Redpath> For example, what do you call the reification of the relationship of > a Participant to a Meeting? A "Participation"? An "Attendance"? > What about a Student to a SchoolClass? A ProjectManager to a > Project? Start pluralizing and things get even uglier. Naked join > tables have their drawbacks, but at least they are easy to name. > > I suppose I could name a class ParticipantEventJoin to get a table > participant_event_joins. While that would make things very obvious > it lacks a certain charm. Maybe there is a better formula for coming > up with a standard name. Any ideas? > > --joshua susser-- Posted via http://www.ruby-forum.com/.
Hi, Now that we are headed for the CRUD-for-everything interface, it seems like naming join models has a little more importances as the user will even more likely see the join model name. Sometimes the join model is needed just to make ordering the items easier using acts_as_list in the join model. I don''t have the naming thing figured out yet either. On 2/18/06, Joshua Susser <joshua@tiralorn.com> wrote:> The thing that makes me cry is trying to name > the darn join model classes.On 2/18/06, Luke Redpath <contact@lukeredpath.co.uk> wrote:> If you are seriously struggling to find a name, it could be a sign that > your join doesn''t really need to be a model.Some examples I''ve seen with good names (all related to people): Author > Authorship < Book Reader > Readership < Book Reader > Reading < Article Person > Membership < Group Person > Attendance < Meeting Student > Enrollment < SchoolClass Employee > Assignment < Project Person > Registration < Conference Some examples I have. Any suggestions? Product, Person > Visualization [polymorphic] < Images Category > Categorization < Product A t-shirt has red or green versions with a SKU each Product > ? < Variation A computer has a cpu and hard drive Product > ? < Part A user as particular role permissions User> ? <Role A user has particular additional permissions User > Abilities? < Permission Can you add to the list? Thanks, Peter
On 7/3/06, Peter Michaux <petermichaux@gmail.com> wrote:> > On 2/18/06, Joshua Susser <joshua@tiralorn.com> wrote: > > The thing that makes me cry is trying to name the darn join model classes. > > Some examples I''ve seen with good names (all related to people): > > Author > Authorship < Book > Reader > Readership < Book > Reader > Reading < Article > Person > Membership < Group > Person > Attendance < Meeting > Student > Enrollment < SchoolClass > Employee > Assignment < Project > Person > Registration < Conference > > Some examples I have. Any suggestions? > > Product, Person, etc > Visualization [polymorphic] < Images > > Category > Categorization < ProductDepartment > Placement < Product> A t-shirt has red or green versions with a SKU each > Product > ? < Variation???> A computer has a cpu and hard drive > Product > ? < PartProduct > Part < Product> A user as particular role permissions > User> ? <RoleUser > Role < Task> A user has particular additional permissions > User > Abilities? < PermissionUser > Permission < Task Maybe I''m getting a little better at this. Peter
I posted on this same topic earlier in week: http://www.ruby-forum.com/topic/73517 I''m running into problems when model objects don''t represent real world things. My model objects (like Views -> Filters -> Groups) only make sense in the context of my app. There is no english word (especially not a noun) for the relationship of a View to a Filter. I''m going with the ViewFilter class name, but I''m not thrilled about it. There''s no good reason it couldn''t be called FilterView. One of the nice things resulting from CRUD design is simplified urls. Awkward relationship names make for awkward urls. In the grand scheme of things this doesn''t really matter, but it seems like there should be an elegant solution. -- Posted via http://www.ruby-forum.com/.
BTW, http://hasmanythrough.rubyforge.org is useful for generating the join model with unit tests etc. -- Posted via http://www.ruby-forum.com/.
Interesting how you find a useful conversation like this AFTER you have resolved your problem. Im starting a list of example join tables for RESTful applications, ive showen my approach and listed some of the examples from the comments above. http://railsnotes.blogspot.com/ '' Naming join models for RESTful applications '' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---