Sep 10, 2011

Mo Moo Moose not really stuttering

M ... Mo ... Moo ... Moose 

(if I were stuttering while I'm typing it would really bad for my brain :) 

is the way everybody should use OO in Perl.

Start from Mo!

Create a class.

package Point2d;
use Mo qw(default);
has x => ( default => sub { 0 } ); 
has y => ( default => sub { 0 } );

Extend it.

package Point3d;
use Mo qw(default);
extends 'Point2d';
has z => ( default => sub { 0 } );

Then somewhere else ...

use Point3d;
my $point = Point3d->new;

And everything is ok ... then, your code grows, you need more features ... just add an o to Mo

and you get a lot of cool stuff from Moo or copy the use string and past it after Mo to use Mouse.

Want much more features? Want introspection? Want antlers? Then switch to Moose.