Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Class confusion when testing using ref()

by tobyink (Abbot)
on Jan 07, 2014 at 16:14 UTC ( #1069673=note: print w/replies, xml ) Need Help??


in reply to Re^2: Class confusion when testing using ref()
in thread Class confusion when testing using ref()

How could I possibly not ++ the above? Your_Mother, your cheque is in the post. ;-)

Anyway, my personal opinion is for OO to default to Moo, and only consider other options if you have special requirements.

  • Use Moose if you have requirements for introspection of your classes.

    But also consider whether introspection is really necessary. For example, if you want to interrogate a class to find which attributes accept, say, an integer, rather than using Moose's meta object protocol to generate the list, you could just add a method to the class called which returns a hard-coded list of such attributes, a la sub integer_attributes { return qw(cell_height cell_width) }

  • Use Moose if you want to take advantage of the many MooseX modules on CPAN. (There's an increasing number of MooX modules though.)

  • Use Moose if your project has dependencies on other projects that already use Moose. Not that using Moo would be a technical problem - Moo and Moose integrate very well. However, it saves people from installing both Moo and Moose, and you may save a little memory by using just one OO system. However, some prominent projects such as Throwable have moved from Moose to Moo.

  • Consider Mouse if speed of generated methods (constructors, accessors) is an important concern, because Mouse implements them in C. Of course, for many projects, it's the methods you write yourself in pure Perl that do the bulk of the work.

    Moo (and also Moose if you install MooseX::XSAccessor) can sometimes, optionally generate XS accessors for you (but not constructors).

  • Use Class::Tiny or Role::Tiny if your requirements are very basic, and you want to keep dependencies at a minimum.

  • Consider Moops if you can tolerate its very large dependency list. (But it has fewer dependencies than MooseX::Declare.)

    Something I use Moops for is rapid prototyping before backporting to plain Moo.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069673]
help
Chatterbox?
[1nickt]: Morning monks, howzit?
[ambrus]: AAAAAAARGH!

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-01-23 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (246 votes). Check out past polls.

    Notices?