note
tobyink
<p>How could I possibly not ++ the above? [Your_Mother], your cheque is in the post. ;-)</p>
<p>Anyway, my personal opinion is for OO to default to [mod://Moo], and only consider other options if you have special requirements.</p>
<ul>
<li><p>Use [mod://Moose] if you have requirements for introspection of your classes.</p>
<p>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 <c>sub integer_attributes { return qw(cell_height cell_width) }</c></p></li>
<li><p>Use Moose if you want to take advantage of the many MooseX modules on CPAN. (There's an increasing number of MooX modules though.)</p></li>
<li><p>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 [mod://Throwable] have moved from Moose to Moo.</p></li>
<li><p>Consider [mod://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.</p>
<p>Moo (and also Moose if you install [mod://MooseX::XSAccessor]) can <em>sometimes, optionally</em> generate XS accessors for you (but not constructors).</li>
<li><p>Use [mod://Class::Tiny] or [mod://Role::Tiny] if your requirements are very basic, and you want to keep dependencies at a minimum.</p></li>
<li><p>Consider [mod://Moops] if you can tolerate its very large dependency list. (But it has fewer dependencies than [mod://MooseX::Declare].)</p>
<p>Something I use Moops for is rapid prototyping before backporting to plain Moo.</p></li>
</ul>
<div class="pmsig"><div class="pmsig-757127">
<small><small><tt>use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name</tt></small></small>
</div></div>
1069326
1069363