Moose is great.
Before Moose, creating objects in Perl was a hassle; you had to write your own constructor, and methods for accessors and mutators. At the same time, you had to try to provide a clean interface and ensure encapsulation. It was tedious. With Moose, you can build your classes without having to include lots of cruft, leaving you to do the interesting stuff.
One advantage of Moose is the ability to mark a class’s attributes as required, and apply typed constraints to those attributes. This means if you try to set an object’s attribute incorrectly, an exception is raised. Nice! However, a lot of developers new to Moose are soon daunted by the truckload of output that is thrown from Moose code. Here’s an example:
Attribute (bar) is required at /home/pete/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux/Moose/Meta/Attribute.pm line 510 Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x1e0e878)', 'Moose::Meta::Instance=HASH(0x1e14ec8)', 'Foo=HASH(0x1429b78)', 'HASH(0x1429170)') called at /home/pete/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux/Class/MOP/Class.pm line 524 Class::MOP::Class::_construct_instance('Moose::Meta::Class=HASH(0x1daf6e0)', 'HASH(0x1429170)') called at /home/pete/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux/Class/MOP/Class.pm line 497 Class::MOP::Class::new_object('Moose::Meta::Class=HASH(0x1daf6e0)', 'HASH(0x1429170)') called at /home/pete/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux/Moose/Meta/Class.pm line 274 Moose::Meta::Class::new_object('Moose::Meta::Class=HASH(0x1daf6e0)', 'HASH(0x1429170)') called at /home/pete/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/x86_64-linux/Moose/Object.pm line 28 Moose::Object::new('Foo') called at /home/pete/perl_scratch/moose_error.pl line 13
It’s a pragma, or a “policy” module, to help people at NAP write more
The module itself is equivalent to a series of
that are considered “a good idea” for our needs.
The distribution also contains a few more “good idea” modules, that
are not tied to any particular application, but can help developers.