|Keep It Simple, Stupid|
Re: Re^2: A few Perl OOP questions. (disparaging)by Zaxo (Archbishop)
|on Oct 23, 2003 at 01:15 UTC||Need Help??|
I think the reason for disparaging that idiom has nothing to do with gifts from absent gods or monopolistic marketing practices. The reason is the idiom indicates an OO design flaw.
The objection is one of OO principle - that class methods and instance methods should be distinct and disjoint. Instance methods deal with the state of a particular object. Class methods deal with class-wide state or instance construction.
Your example is a common idiom only because it's one way ref($foo) || $foo methods are called. If it's necessary to intuit $one's class, why not say so by writing
my $two = ref($one)->new('b');
There is a borderline case - copy constructors. It is tempting to be able to write
my $two = $one->new();
Tye, I thought you disliked cries of "Cargo Cult!" ;-)