Though it's dangerous to attempt to identify emotion from email/text, I feel from your response that I may have offended you. If so, I apologize; my intent was not to make a personal attack on you or your decisions. Rather, I was only trying to express my own opinion about the method names. If I didn't offend you, and have misinterpreted your vigorous and thorough explanation of your rationale as emotional...well, then I also apologize. :)
On Mar 8, 2009, at 8:35 PM, Jeremy Evans wrote: > On Mar 8, 3:17 pm, Gavin Kistner <[email protected]> wrote: >> On Mar 6, 2009, at 3:44 PM, Jeremy Evans wrote: >> >>> Also, note that belongs_to will be deprecated in the next version. >>> Use many_to_one. >> >> Really? That's a shame, IMHO. >> I know it's from AR, but that doesn't mean it's bad :) > > I'm not removing it just because it is used by AR. It was added by > the previous maintainer against my advice, simply to make conversion > easier for AR users. I'm removing it because I think the method names > are bad. For the record, the smiley was intended to convey that I find it humorous to suggest that you would do something as spiteful as removing a feature just because it happened to have an association with Active Record. I trust that you have the best interests of Sequel and its users in mind, and are not trying to (further) distinguish Sequel from its sort-of competitor. > I think belongs_to is stupid method name. A book doesn't belong to an > author, as that implies ownership. has_and_belongs_to_many is > probably the stupidest name, as it implies ownership both ways, which > generally makes no sense. has_many isn't that bad, except even in a > many to many situation I think has_many would be just as descriptive, > which is why it's a bad idea to use it for just one association type. An interesting point. Does it make sense to say that a teacher "has many" students, without implying that the teacher owns them? I think so. But I'd agree that it doesn't make sense to say that a student "belongs to" a teacher (in lower grades with a single teacher for an entire grade) or that a student belongs to many teachers (when a student has different teachers for various subjects) . Or (worse) that in the many_to_many case that a teacher in any way ever belongs to a student. You've convinced me. habtm and belongs_to are both likely not properly representative of the real-world relationships between the objects being modeled. >> "Jorble one_to_many :bongle" (Or is it bongles?) >> I really, truly, not-lying-because-it-helps-my-argument, have no idea >> which is the one and which is the many. > > It's easy. On on "MyModel.x_to_y :associated_model" call, the MyModel > is the x in the associatied_model is the y. So for Jorble > one_to_many :bongles, Jorble is the one and bongles is the many. If > the association method ends in many, you use the plural form, > otherwise, you use the singular form. I suppose it is more natural if > you come from a database background, where people use terms like one > to many and many to one (or 1->N and N->1), and nobody uses terms like > belongs to to describe relationships between tables. I do come from a database (and computer-science) background. I absolutely understand the concept of one-to-many et al. And I don't dispute that there's an easy mnemonic for remembering which to apply. It's just that (for me) reading it doesn't describe what's going on. I have to break out my (super-simple) encoder ring every time I need to decide which to write, and my (super simple) decoder ring when reading the code. It's not that I don't understand what one_to_many means, but rather that it is not clear to me which is the one and which is the many. It's as though I had a Person object with a method named #uncle_nephew. Gavin.uncle_nephew( Hayden ). Sure, it's easy to document that the receiver is the uncle and the argument is the nephew. And it's easy to defend the ordering from a left-to-right perspective. But (IMHO) it would be far clearer and self-documenting to instead name the method "is_uncle_of" or "nephew=". (This analogy obviously falls a little short, as uncleness/auntness/ nephewness/neiceness is determined by a sex property of those involved, whereas the oneness/manyness can not be determined by the objects involved.) >> I like my method calls (that >> take arguments and do something, as opposed to accessors) to be >> verbs. >> This isn't one, and I feel it. "Thing thing :thing". What? > > I like my method calls to make sense. Method calls should be verbs > only if they are actions. Association methods are the way you > describe to Sequel how models are connected to each other. There are > no actions, so I don't see a reason to use verbs. You end up with bad > method names like has_and_belongs_to_many if you do that. I could argue that all method calls that change any state (not purely functional) can be considered 'actions'. (Isn't changing an instance variable an action?) So there's some movable conceptual line of what is setting a property and what is invoking an action. In your mental model, I suppose, one_to_many is setting a property. In my mental model, it is causing various methods to be generated. If I were in charge of Sequel (which I'm not, and so of course accept your decisions) I would probably call them: references_a referenced_by joins_with (or something similar) But, it's not a big deal. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
