in reply to Law of Demeter and Class::DBI
and$o->thing1->thing2->thing3
being replaced withSELECT thing2.thing3id FROM o, thing1, thing2 WHERE O.id= ? AND o.thin +g1_id = thing1.id AND thing1.thing2id = thing2.id
and$o->thing123
SELECT thing123id FROM view123 WHERE o.id = ?
A view allows you to reach across relations without having to explicitly traverse them. It's a bit different to a stored procedure in that it's easier to express and the DB understands what it does on a deeper level and is able to think about it and optimise. In most OO systems thing123 must be implemented like a stored procedure because the languages don't have a good way of expressing relationships. Once you're doing things the stored procedure way, the language no longer really understands what your doing and so it cannot be smart, it just has to follow your instructions to the letter, with the result that you are forced to write detailed instructions and more of them.
In an OO language you end up with setters and getters because the language can't look inside thing123 to see that actually it's just ->thing1->thing2->thing3 and that it could use this for both the setter and the getter. Perl is different, it has lvalue subs. Lisp goes all the way with it's handling of getters, setters and macros, if you defined thing123 properly it is automatically both a getter and a setter and will interact nicely with all the other well defined getters and setters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Law of Demeter and Class::DBI
by Anonymous Monk on Nov 16, 2004 at 18:22 UTC | |
by fergal (Chaplain) on Nov 17, 2004 at 11:37 UTC | |
by jplindstrom (Monsignor) on Nov 19, 2004 at 22:09 UTC | |
by fergal (Chaplain) on Nov 20, 2004 at 00:51 UTC | |
by jplindstrom (Monsignor) on Nov 20, 2004 at 12:34 UTC | |
by diotalevi (Canon) on Nov 19, 2004 at 22:22 UTC | |
by fergal (Chaplain) on Nov 20, 2004 at 00:52 UTC |