Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Object Oriented Perl - very basic guide

by jeffa (Bishop)
on May 15, 2014 at 14:24 UTC ( [id://1086145]=note: print w/replies, xml ) Need Help??


in reply to Object Oriented Perl - very basic guide

You should consider using Moose instead:

package MyObject; use Moose; use MooseX::FollowPBP; has state => ( is => 'rw', isa => 'Any' ); 1;

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Object Oriented Perl - very basic guide
by Preceptor (Deacon) on May 15, 2014 at 14:33 UTC

    I'd generally agree - what I was aiming to do was outline the basics. Personally I find I understand things lots better if I do it the 'hard way' first, then throw it away and go and find a module to do it.

      I learned OO long before i learned Perl, via Java and C++. When introduced to Perl's OO, i was initially baffled. Perl has a less than perfect OO system. I would only discuss Perl's OO "internals" (i.e. having to bless a thingy to a package via a sub called "new") in an advanced chapter, after the more useful stuff like composition and roles have been discussed, personally. It tends to turn people off, seeing that new sub ...

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      

      I have held the opinion for quite a while now that better one understands "classic" Perl OO the more one can understand just what Moose (and the rest) are doing for you. And depending upon circumstances and/or goals (such as the $work environment) it might not be feasible to take advantage of them. If that is the case, then a solid understanding of classic OO allows you to do pretty much the same thing but in the restricted environment.

      My favorite tutorial by far has been the Animal Farm (Talk with the Animals) one, it is listed above but is no longer part of the core distro. :(

      It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
Re^2: Object Oriented Perl - very basic guide
by Arunbear (Prior) on May 16, 2014 at 10:04 UTC
    Only if you need the meta object protocol. If you don't need it, Moo can do most of what Moose can but without the slow start up time and memory/dependency bloat.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1086145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found