On Tue, Feb 11, 2014 at 12:42 AM, Uri Guttman <u...@stemsystems.com> wrote:
> On 02/11/2014 12:13 AM, shawn wilson wrote:
>>
>> On Mon, Feb 10, 2014 at 11:50 PM, Uri Guttman <u...@stemsystems.com> wrote:
>
>
>>>> sub new
>>>> {
>>>>     my ($proto) = @_;
>>>>     my $class = ref($proto) || $proto;
>>>
>>>
>>>
>>> don't do that style of getting the class. it is meant to handle class or
>>> object method calls and is considered poor design.
>>>
>>
>> So, I guess the question is, why? I'll read a blog or other reference
>> if that's easiest.
>
>
> new() should be a class method that only gets the class passed to it. if you
> want object methods to create new objects, call them clone or similar. they
> are different concepts, creating a new object or creating one from an
> existing object. usually clone will also initialize the new object from the
> old one. that is a very different thing than just creating a new object.
>
> so that idiom has been around for a long time and isn't needed in most
> cases. you don't see it much in new code and it usually marks cargo cult
> copying of an idiom with no real reason behind it. did you expect to call
> your new() with an object vs a class name? if not, then you don't need that
> code.
>

I kinda got that's what it was for, I just never thought it was a bad
idea.... I also don't have any real use for the functionality in what
I'm working on. I guess the thought was that, why take something away
that someone might want to use that doesn't have any negative
ramifications - which I still don't see why this is bad?

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to