There are two camps of learning Perl OO. The first is that you should learn all the various pieces of building an OO system and grab modules off CPAN that do individual things. This is the traditional way of doing OO in Perl.

The other is to start with Moose which is a great system that does everything you need.

I am strongly in favor starting with Moose. Why? Several reasons. OO is all about abstraction and composition and interfaces. It is about burying how your code does it's work and focusing on just that it does what it says it does. Digging into the nitty gritty details of building an OO system and picking and choosing your pieces is the antithesis of that.

Moose has everything you need all in one package. Roles, attributes, introspection... it's all there. The bits and bobs on CPAN? They each implement part of the problem. Maybe they work together, maybe they don't.

Moose is very heavy, but if it's too heavy for you there's Mouse which has no dependencies. They interoperate well and there's Any::Moose to decide between them.

TMTOWTDI but Moose is a pretty good one which Perl 5 is (finally) converging on. You can write a Moose class and be pretty sure any given Perl programmer will understand it. If they don't, they just have to learn one module... one they're going to have to learn anyway. If you need advice, you can get it. If you write something by hand or pull bits off CPAN, who knows if it's a module someone is familiar with.

Finally, the stuff in the core docs is really, really, really out of date and gives some bad advice. It's far too focused on HOW to build an OO system and not what you should be doing with it.


In reply to Re: OO and Perl by schwern
in thread OO and Perl by Anonymous Monk

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.