Thread MooseX::Role::Parametrized in Mouse nachgebaut (7 answers)
Opened by barney at 2018-08-29 13:16

rosti
 2018-09-05 07:46
#188877 #188877
User since
2011-03-19
3199 Artikel
BenutzerIn
[Homepage]
user image
Moin,

ist Moose überhaupt best practice?

Das Beispiel

Code (perl): (dl )
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; # automatically turns on strict and warnings
 
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

View full thread MooseX::Role::Parametrized in Mouse nachgebaut