Moin,
ist Moose überhaupt best practice?
Das Beispiel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Point;
use Moose;
has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');
sub clear {
my $self = shift;
$self->x(0);
$self->y(0);
}
package Point3D;
use Moose;
extends 'Point';
has 'z' => (is => 'rw', isa => 'Int');
after 'clear' => sub {
my $self = shift;
$self->z(0);
};
sieht für mich nicht nach best practice aus! Weil die Zeile, in welcher eine Instanz mit new() erzeugt wird überhaupt nicht vorkommt. somit ist in dieser Hinsicht der Code ein Crypt und nicht nachvollziehbar.
Was
extends 'Point'; betrifft: Subklassen erweitern nicht sondern spezialisieren.
MfG