>>>>> "M" == M W Koskamp <[EMAIL PROTECTED]> writes:
M> sub connect{
M> my $class = shift;
M> my $class = ref($class) || $class;
M> return bless $class->SUPER::connect(@_), $class;
M> }
Please remove the ref($class) || $class there. That bad meme seems to
continue to spread like wildfire.
"connect" is a class method, not an instance method. It doesn't make
sense (and I'd fail it in a code review) to have "connect" being
called on an instance to get a new object of the same type. If you
really *ever* want to do that, you can use the idiom:
(ref $dbh)->connect(...)
which is clearly "call the class that this object is associated with,
and select its connect method". If you replace that with
$dbh->connect(...)
then I get lost about whether it means "reconnect this handle" or
"create a new handle" or "clone this handle including its connection
parameters" very quickly.
Clarity, people. Clarity.
Let class methods be class methods. Instance methods be instance
methods. Especially for constructors.
Just another guy who has been OO-programming for *21* years,
and a member of the "help stamp out ref($class)||$class meme" committee!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!