On 12/27/05 8:11 PM, Daniel Pittman wrote:
> As I mentioned, I can't see why I would want to get the ID, rather than
> the object

There are a few reasons.  The first, and most obvious, is that sometimes you
want the id and sometimes you want the thing it refers to.  Maybe you never
needed the id, but trust me when I tell you that many people do :)  When you
have just one method name, you end up playing games and adding non-obvious
behavior in order to make that one method serve both needs.

Second, the "foo_id" naming scheme for foreign key columns is pretty common,
and having a method called foo_id() that *doesn't* return an id is odd at
best, and "broken" at worst.

Finally, although this is not really an issue in Class::DBI due to its
historically poor support of this feature, you need a separate method name
for "the thing referred to by this group of columns" in the case where a
foreign key has multiple columns.  RDBO supports "multi-column everything"
(primary keys, foreign keys, unique keys, and relationships of all types) so
it has to have separate names for all such methods, in the general case.

I'm actually surprised to hear your opinion on this issue since most of what
I hear from long-time Class::DBI users is the exact opposite: joy at
discovering the "the method that gets the object" and "the method that
returns the id" are--finally!--separate things.

Anyway, "feature, not bug!" as they say :)

-John




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to