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

Re: OO and Perl

by schwern (Scribe)
on Mar 31, 2011 at 05:40 UTC ( #896559=note: print w/replies, xml ) Need Help??


in reply to OO and Perl

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.

Replies are listed 'Best First'.
Re^2: OO and Perl
by nikosv (Chaplain) on Apr 01, 2011 at 17:21 UTC
Re^2: OO and Perl
by Anonymous Monk on Mar 31, 2011 at 06:14 UTC
    BTW how is Perl5i going?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://896559]
help
Chatterbox?
[stevieb]: man, I absolutely LOVE driving in the worst winter conditions. In the mountainous roads, there are extremely few (if any) other drivers. I love the challenge. I've been doing extreme off-road my whole life, and as I said, I'm always well...
[stevieb]: ...prepared for even the very worst
Discipulus seems a part of the globe very unfrindly with Kawasaki riders..
[thezip]: My doggies love it when it snows
[perldigious]: As long as you are a good "boy scout" stevieb, more power to you... but I like my Jeep, and don't like the idea of rolling it or crashing it in to anything. :-)
[thezip]: Me, not as much.
[perldigious]: Mine too thezip, especially my German Shepherd. He looks like he is about to die of heat exhaustion all summer, so he goes nuts when winter comes and he can play in the snow.
[stevieb]: my main off-road vehicle nowadays is a strengthened mercedes ML320. I'm very hard on it, but I've never had any real issues at all (I love how small and light it is, and it has a very, very good centre of gravity for how I roll)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2016-12-06 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.