Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

The heart of this question is what your model of OO programming is.

Is it? I'd say that for me, this boils down to the following considerations:

  1. Do you want to or need to permit someone to call either $obj->new() or (ref $obj)->new()? (Typically, no. Consequently, on those occassions where I've done this I've got to admit it has been cargo-cult. But now that I'm aware of this, I come to the next question...)
  2. Even if you don't need this, are you going to permit this anyway? Are you going to allow someone else to do this with your module, and to do this as a direct object method, without calling ref($obj)? (And here, my answer is "Why not -- how could it hurt?")
  3. If you say 'yes' to either of the above, are you confused by the name of the method new(), so that you don't know if it clones or not? And my answer is, "No! If I wanted the method to clone, I'd've named it clone() and not new()!"

In short, for me it's a matter of interface preferences, and how strict/permissive I want to be with that. The philosophy of it all only comes down to the simple question of whether it makes sense for new() to ever behave as clone(). To me it doesn't; this may be because I only really learned OO via Perl (and some Java) so I'm not influenced by Smalltalk or other languages.

-- Frag.

In reply to Re: Re (tilly) 2: Paradigm Shift - Dual Use Constructors by frag
in thread Paradigm Shift - Don't use strict by Ovid

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (8)
    As of 2014-12-27 01:52 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (176 votes), past polls