Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-25 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found