Thanks a lot for all replies - we'll probably go with Moose now.
I have one more question:
In a previous project I've used Class::Std and I quite like the strong encapsulation for object-attributes it provides.
I just did some (very basic) playing around with Moose and wonder if there is any way to encapsulate object-attributes as well or if with Moose no access-control is possible.
For example I was very surprised that you could do the following:
<code>
use strict;
package Hubba;
use Moose;
has 'hubba' => ( is => "rw", isa => 'Int' );
package main;
no Moose;
my $h = Hubba->new;
$h->{hubba} = "Bubba";
print $h->hubba
</code>
This actually prints "Bubba". In this example I declare a "hubba"-attribute of a "Hubba"-class to be of type Int, but still it is possible to subvert the type-system by accessing the attribute directly (or am I doing something wrong?)
I don't think all of this will be a major concern for us, but still I would prefer stronger encapsulation - is that possible with Moose (or can you mix Moose and Class::Std)?
Many thanks! |