Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Class confusion when testing using ref()

by atcroft (Abbot)
on Jan 05, 2014 at 06:15 UTC ( [id://1069361]=note: print w/replies, xml ) Need Help??


in reply to Class confusion when testing using ref()

My thanks for all of the responses, especially to chromatic and tobyink-making that change appears to have solved my issue. AnomalousMonk, I removed the @ISA assignment, and the code works, so that appears to have been my misunderstanding. With regards to the comments of chromatic and BrowserUK on the next module to use, I've heard mention of such modules as Moose, Mouse, and Mo-what is the current, generally-recommended state of the art?

Again, my thanks and appreciation for the assistance and insight. Thank you all!

  • Comment on Re: Class confusion when testing using ref()

Replies are listed 'Best First'.
Re^2: Class confusion when testing using ref()
by Your Mother (Archbishop) on Jan 05, 2014 at 06:58 UTC

    All the modules mentioned are “state of the art” since they are all actively maintained and really quite nice. Also missed Moo, and for bleeding edge fun you might look at Moops. Moose does more than the others; see Class::MOP for why/how. It’s also the slowest (really start up is the major issue, it’s not “slow” exactly once compiled and running) and the others through their minimalism achieve, maybe… subjective, cleaner interfaces and extensions. Mouse with XS is the fastest by a lot. I’ve been reaching for Moo most of the time. I didn’t know Mo had grown so much since it was sort of what I saw as a joke response to it all. I would probably use Moops for personal projects if I had the tuits for personal projects right now.

    On that note I’d like to say that tobyink is really quite an excellent—and prodicious!—software designer. See also, Type::Tiny.

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1069361]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found