Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Free tutorial on Object Perl (Object-Oriented Perl)

Reply
Thread Tools

Free tutorial on Object Perl (Object-Oriented Perl)

 
 
tim@timothyhowe.com
Guest
Posts: n/a
 
      12-22-2005
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.

Part 2 builds on Part 1 by adding subclasses to demonstrate
inheritance. It also demonstrates the use of objects to model a
many-to-many relationship.

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      12-22-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.


I fail to see how this could be considered any better than
perldoc perltoot
perldoc perlobj
or the Alpaca

> Part 2


.... is a HTTP 500

Paul Lalli

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      12-22-2005

(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial or Example (or Tutorial) of Using Canvas to Produce a Plot W. Watson Python 13 09-20-2007 04:29 PM
Tutorial for beginner/ Tutorial voor beginner Rensjuh C++ 7 09-02-2004 12:41 AM



Advertisments