wrote:
> In the many years since Object Perl first appeared, I never found an
> introduction or tutorial that I liked. So I wrote my own.
>
> The tutorial is at
>
> http://www.timothyhowe.com/software
>
> (click on Object Perl).
>
> The Object Perl Tutorial, Part 1 presents a very compact explanation of
> object programming using Perl, illustrated with a complete working
> example program, without subclasses.
In Perl TMTOWTDI.
However there are a number conventions that your tutorial ignores:
Object constructors are conventionally called 'new' (not 'create')
unless there's a reason to call them something else.
Within an instance method the current object is conventionally called
$self (not $this).
Method calls should conventionally use the -> syntax rather than
indirect objects except in a few special cases.
Programs using objects should not fiddle with their internals.
Certainly you should think of the value of the Dog consttuctor as
being of type 'Dog' and not put it in a variable that has 'HR' (as an
abreviation of 'hash reference') in the name.
($thisRH->{name}, $thisRH->{weight}, $thisRH->{voice}) would more
conventionally be written as a slice.
Your example says
$carlRH = create Dog ('Carl', 14, 'Yap');
It is exceptionally rare in real (well written) code to want to store
the return value of a constructor into an existing scalar variable. As
such it would be more realistic for you example to say:
my $carl = Dog->new('Carl', 14, 'Yap');
Oh, and bless() modifes the _referent_ not the _reference_.
my $thing = {};
my $another_reference = $thing;
print ref $another_reference; # Prints HASH
bless $thing, 'Some::Class'; # Modifies %$thing
print ref $another_reference; # Prints Some::Class