http://www.perlmonks.org?node_id=301439


in reply to Re^2: A few Perl OOP questions. (disparaging)
in thread A few Perl OOP questions.

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(); for a deep copy of $one. Reflection on how much different that operation that is from construction with a parameter list suggests that a separate copy ctor is advisable, my $two = $one->clone(); , an instance method. That could be written as a class method, my $two = Purified::Confusion->new($one); , but that would make for an unnecessarily complicated constructor.

Tye, I thought you disliked cries of "Cargo Cult!" ;-)

After Compline,
Zaxo