Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"

[prev] [thread] [next] [Date index for 2005/07/26]

From: Michael G Schwern
Subject: Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"
Date: 06:48 on 26 Jul 2005
On Tue, Jul 26, 2005 at 04:21:27PM +1200, Sam Vilain wrote:
> This, to me, represents a part of the seductive over-simplicity of
> Class::DBI; hiding the database handle details in a package global is
> pretty nasty, for this and other reasons.  Much better to pass it around
> as a lexical.

Point of fact: Its not in a package global, its class data [1] and thus
easily overridable.  You do it every time you call connection().  And 
because you access the database handle via a method the user never knows
how its stored, and really shouldn't care.

The design split is instead per class vs per object connections.  In CDBI 
if you want to access the same table with the same class in two different
databases at the same time you have to make a subclass and call connection()
which is where the per class database handle design choice goes thud.  At
the time of Ima::DBI's design I had silly ideas about not wanting to store 
anything in the object.  I also thought pseudohashes were a good idea.

The WORST possible thing you could do is pass around the database handle
to each method.  That just mucks up the interface with redundant data which
really should live in the object (or class).

[1] See Class::Data::Inheritable for details.


        -- 
        Michael G Schwern     schwern@xxxxx.xxx     http://www.pobox.com/~schwern
'All anyone gets in a mirror is themselves,' she said. 'But what you
gets in a good gumbo is everything.'
	-- "Witches Abroad" by Terry Prachett

(message missing)

Delegation vs Hooks (was: Annouce: DBIx::Class, a.k.a "taking the easy way out")
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 23:27 on 26 Jul 2005

Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"
Michael G Schwern 06:48 on 26 Jul 2005

Generated at 16:36 on 28 Jul 2005 by mariachi v0.52