From: Chris W. <ch...@cw...> - 2004-12-01 18:48:35
|
>... > I think that both links_to and has_many share a fundamental flaw. They > both allow relationships to be defined from the "other" end, making it > possible to define conflicting behavior for a single relationship. This > unnecessarily complicates the error checking or precedence rules and > the documentation. I think always forcing the relationship to be > defined by the class with the linking field, and having a single syntax > (has_a) for defining it, makes for a much simpler, cleaner, more > consistent, easier to understand/document/implement, less error prone > design. Including both approaches (e.g. has_many and reverse_auto or > auto_by), in my opinion, only complicates and confuses things further. Good point. > For this reason, I think we should forget trying to make the new syntax > backward compatible. I think we should leave the old syntax in place > (but deprecated) as long as necessary for backward compatibility and > add a completely redesigned new syntax that folks can migrate to > gradually or as they need the new features. If it were up to me I > wouldn't touch links_to at all, and I wouldn't touch the old has_a > either. I'd just add a new configuration handler for the case where the > key of a 'has_a' spec matches one of the field names, in which case you > assume it is the new syntax I proposed, otherwise you assume it's a > class and use the old has_a semantics. My main concern is that we don't break existing code. Everyone seems to also be avoiding this so: great. Next is ensuring that new features are easily implemented, testable and maintainable. I suspect Ray's right in that overloading existing syntax will make all of these more difficult. I'm not against adding new syntax/configuration keys as necessary and if it takes care of both of these items, it's probably the best option. > [1] I confess I never really did understand the purpose of the alias. > What is the difference between the alias and the class? Isn't one of > them redundant? Yes, but IME most humans prefer the alias (e.g., 'news') vs. the class ('MyApp::Persist::News'). Plus it's less typing :-) Chris -- Chris Winters (ch...@cw...) Building enterprise-capable snack solutions since 1988. |