In theory, $obj->new( ... ) is ambiguous and should be avoided. Very often, in practice, the meaning of $obj->new( ... ) is obvious and useful.

The bigger mistake is using a method generator, especially one that leaks information that should be internal to the implementation (the attribute names) to the external interface (including the constructor).

A bigger mistake than that is even contemplating "before" hooks. And some (but not all) of the reasons why they are a horrible method of abstraction are actually demonstrated above.

But, yes, I have several times implemented class-only (and even more likely, object-only) methods. I'm most likely to do that by having a different package for class methods vs object methods.

I encourage you to take a step back and give more thought to your primary goals and reassess your secondary goals. In this context, OO purity is a secondary goal, one meant to be a shortcut to evaluating likely usefulness toward primary goals, mostly modular design.

Moose is anti-modular. If you avoid all of the anti-modular features of Moose (which you can), then you are left with no benefits (but real overhead costs).

- tye        


In reply to Re: $class = ref($class) if ref($class) Redux (theory) by tye
in thread $class = ref($class) if ref($class) Redux by boftx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.