"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I would say that simply having an OO interface is a big advantage. The popularity of Class::DBI seems to suggest that people enjoy accessing their relational data as objects.
There seem to be a few problems with the tied hash approach. For inflating foreign keys and other functions, Tie::Table is forced to mix OO/hashref metaphors (Tie::DBI doesn't seem to support foreign key inflation which really limits the comparison). From its POD: Its POD goes on to scare/confuse me with this: I've never extensively used tied objects, but I'm wondering if this strange behavior is somehow related to the difficulty of nesting, returning tied objects? It's also not clear whether I can add other non-persistent attributes and methods to these objects. With OO, I can always add subclass data, helper methods, etc. The only thing I can see in favor of having objects as hashes is for quicker glueing with HTML::Template. Of course, I could always add a ->to_hash method to my objects as well ;) Also, one of my key reasons for doing this module is so that I never have to tell some interface about how my tables are related. With those modules, you have to set up a tied hash for each table, telling it about your primary key and foreign keys. Obviously you could make a wrapper to scan your database and build the appropriate tied hashes, but if my module can do it out of the box, why not? I know there's nothing earth-shattering about this idea, but it's saved me a lot of time along the way. blokhead In reply to Re: Re: Module RFC: Yet another object-persistence interface
by blokhead
|
|